simplex2/app.moon

34 lines
895 B
Plaintext
Raw Normal View History

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