feed username into login when failure

This commit is contained in:
Kyle Drake 2014-03-27 15:36:33 -07:00
parent 355a4a1c86
commit 0ccfac7405
No known key found for this signature in database
GPG key ID: 8BE721072E1864BE
3 changed files with 5 additions and 1 deletions

3
app.rb
View file

@ -134,11 +134,13 @@ end
post '/signin' do
dashboard_if_signed_in
if Site.valid_login? params[:username], params[:password]
site = Site[username: params[:username]]
if site.is_banned
flash[:error] = 'Invalid login.'
flash[:username] = params[:username]
redirect '/signin'
end
@ -146,6 +148,7 @@ post '/signin' do
redirect '/dashboard'
else
flash[:error] = 'Invalid login.'
flash[:username] = params[:username]
redirect '/signin'
end
end

View file

@ -24,6 +24,7 @@ html
.page
.container
- flash.keys.each do |key|
- next unless %i{success error}.include? key
div class="alert alert-#{key}"
button.close type="button" data-dismiss="alert" ×
== flash[key]

View file

@ -6,7 +6,7 @@
input name="csrf_token" type="hidden" value="#{csrf_token}"
fieldset.col-60 style="margin:0 auto"
input name="username" type="text" placeholder="Your username" class="input-Area" autocapitalize="off" autocorrect="off"
input name="username" type="text" placeholder="Your username" class="input-Area" autocapitalize="off" autocorrect="off" value="#{flash[:username]}"
br
input name="password" type="password" class="input-Area" placeholder="Your password"
br