34 lines
895 B
Plaintext
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 > 0
|
|
table.insert @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 }
|