Simplify a big part of the logic

This commit is contained in:
Sam Dodrill 2015-01-08 13:22:26 -08:00
parent ff4eee25bc
commit 6594600a03
3 changed files with 12 additions and 13 deletions

View File

@ -50,20 +50,11 @@ class User extends lapis.Application
token: encoding.encode_base64 encoding.hmac_sha1(@params.email, os.time!) token: encoding.encode_base64 encoding.hmac_sha1(@params.email, os.time!)
} }
@title = "Success" @session.token = encoding.encode_base64 token.token
@html -> @session.flash = "You are logged in. Your extension is #{user.extension}."
h1 "Success"
p ->
text "Your email is " .. user.email
p ->
text "Your extension is " .. user.extension
p ->
text "Your one-time sip token is "
code token.token
p "This will not be shown again so please be sure to write this down."
redirect_to: @url_for "index"
} }
[login: "/login"]: capture_errors respond_to { [login: "/login"]: capture_errors respond_to {

View File

@ -1,4 +1,3 @@
db = require "lapis.db"
import Model from require "lapis.db.model" import Model from require "lapis.db.model"
export class Users extends Model export class Users extends Model
@ -6,3 +5,8 @@ export class Users extends Model
write_session: (r) => write_session: (r) =>
r.session.user = @id r.session.user = @id
read_session: (r) =>
if r.session.user
return @find id: r.session.user
nil

View File

@ -6,5 +6,9 @@ class Index extends Widget
div class: "body", -> div class: "body", ->
text "Welcome to my site!" text "Welcome to my site!"
if @flash
p class: "flash", ->
text @flash
if @user if @user
h2 "I think you are UID #{@user}" h2 "I think you are UID #{@user}"