Use flashes
This commit is contained in:
parent
05aaa39e17
commit
b5984b43ec
2
app.moon
2
app.moon
|
@ -16,5 +16,5 @@ class App extends lapis.Application
|
|||
@session.flash = nil
|
||||
|
||||
[index: "/"]: =>
|
||||
@user = @session.user
|
||||
@name = @session.name
|
||||
render: true
|
||||
|
|
|
@ -81,6 +81,7 @@ class User extends lapis.Application
|
|||
token: encoding.encode_base64 encoding.hmac_sha1(@params.email, os.time!)
|
||||
}
|
||||
|
||||
@session.token = encoding.encode_base64 token.token
|
||||
@title = "Login successful"
|
||||
|
||||
return "Hi " .. user.name
|
||||
|
|
|
@ -69,5 +69,10 @@ class Layout extends Widget
|
|||
|
||||
body ->
|
||||
@header!
|
||||
|
||||
if @flash
|
||||
div class: "flash", ->
|
||||
text @flash
|
||||
|
||||
@body!
|
||||
@footer!
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
body {
|
||||
padding-top: 50px;
|
||||
padding-top: 60px;
|
||||
}
|
||||
|
||||
html {
|
||||
|
@ -15,3 +15,13 @@ html {
|
|||
height: 50px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.flash {
|
||||
background: #cee5F5;
|
||||
padding: 0.5em;
|
||||
border: 1px solid #aacbe2;
|
||||
}
|
||||
.error {
|
||||
background: #f0d6d6;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
|
|
@ -6,9 +6,5 @@ class Index extends Widget
|
|||
div class: "body", ->
|
||||
text "Welcome to my site!"
|
||||
|
||||
if @flash
|
||||
p class: "flash", ->
|
||||
text @flash
|
||||
|
||||
if @user
|
||||
h2 "I think you are UID #{@user}"
|
||||
if @name
|
||||
h2 "I think you are #{@name}"
|
||||
|
|
Loading…
Reference in New Issue