2018-03-13 09:15:38 +00:00
|
|
|
import Application from require "lapis"
|
|
|
|
import Keys, Tasks from require "models"
|
2018-03-16 23:33:32 +00:00
|
|
|
import autoload, locate, registry from require "locator"
|
|
|
|
import settings from autoload "utility"
|
2018-03-13 09:15:38 +00:00
|
|
|
|
|
|
|
class extends Application
|
2018-03-16 23:33:32 +00:00
|
|
|
@before_filter =>
|
|
|
|
settings.load!
|
|
|
|
registry.before_filter(@)
|
2018-03-13 09:15:38 +00:00
|
|
|
|
2018-03-16 23:33:32 +00:00
|
|
|
-- layout: "layout"
|
|
|
|
@include locate "users"
|
|
|
|
@include locate "api"
|
2018-03-13 09:15:38 +00:00
|
|
|
|
2018-03-16 23:33:32 +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
|
|
|
|
2018-03-16 23:57:52 +00:00
|
|
|
unless @keys and #@keys > 0
|
|
|
|
@keys = {Keys\create user_id: @user.id}
|
2018-03-13 09:15:38 +00:00
|
|
|
|
2018-03-16 23:33:32 +00:00
|
|
|
return render: "index.logged_in"
|
2018-03-13 09:15:38 +00:00
|
|
|
|
2018-03-16 23:33:32 +00:00
|
|
|
else
|
|
|
|
return redirect_to: @url_for "user_login"
|
|
|
|
-- TODO
|
|
|
|
-- return render: "index.logged_out"
|
2018-03-13 09:15:38 +00:00
|
|
|
|
2018-03-16 23:33:32 +00:00
|
|
|
-- [generate_api_key: "/generate_api_key"]: =>
|
|
|
|
-- if @user
|
|
|
|
-- if key = Keys\create user_id: @user.id
|
|
|
|
-- return json: { success: true, :key }
|