33 lines
865 B
Plaintext
33 lines
865 B
Plaintext
import Application from require "lapis"
|
|
|
|
import APIKeys, Tasks from require "models"
|
|
import autoload, locate, registry from require "locator"
|
|
import settings from autoload "utility"
|
|
|
|
class Simplex extends Application
|
|
@before_filter =>
|
|
settings.load!
|
|
registry.before_filter(@)
|
|
|
|
@include locate "users"
|
|
@include locate "api"
|
|
|
|
[index: "/"]: =>
|
|
-- NOTE TEMPORARY
|
|
if @user
|
|
@keys = APIKeys\select "WHERE user_id = ?", user_id: @user.id
|
|
@tasls = Tasks\select "WHERE user_id = ?", user_id: @user.id
|
|
|
|
unless @keys and #@keys > 0
|
|
@keys = {APIKeys\create(@user)}
|
|
|
|
return render: "index.logged_in"
|
|
|
|
else
|
|
return redirect_to: @url_for "user_login", nil, redirect: @url_for "index"
|
|
|
|
[new_api_key: "/new-api-key"]: =>
|
|
if @user
|
|
if key = APIKeys\create(@user)
|
|
return json: { success: true, :key }
|