simplex2/app.moon
2018-03-16 16:57:52 -07:00

34 lines
895 B
Plaintext

import Application from require "lapis"
import Keys, Tasks from require "models"
import autoload, locate, registry from require "locator"
import settings from autoload "utility"
class extends Application
@before_filter =>
settings.load!
registry.before_filter(@)
-- layout: "layout"
@include locate "users"
@include locate "api"
[index: "/"]: =>
if @user
@keys = Keys\find user_id: @user.id
@tasks = Tasks\find user_id: @user.id -- TODO convert to paginated
unless @keys and #@keys > 0
@keys = {Keys\create user_id: @user.id}
return render: "index.logged_in"
else
return redirect_to: @url_for "user_login"
-- TODO
-- return render: "index.logged_out"
-- [generate_api_key: "/generate_api_key"]: =>
-- if @user
-- if key = Keys\create user_id: @user.id
-- return json: { success: true, :key }