summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/sessions_controller.rb19
-rw-r--r--app/views/sessions/new.html.erb4
2 files changed, 12 insertions, 11 deletions
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index fa5d024..a74cbd3 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -2,9 +2,7 @@ class SessionsController < ApplicationController
# GET /sessions/new
def new
- if @user.nil?
- @user = User.new
- end
+ @user = User.new
end
# POST /sessions
@@ -12,12 +10,15 @@ class SessionsController < ApplicationController
# find the user...
@user = User.find_by(email: params[:session][:email].downcase)
# ... and create a new session
- if @user && @user.authenticate(params[:session][:password])
- sign_in @user
- redirect_to root_path
- else
- redirect_to new_session_path
- end
+ respond_to do |format|
+ if @user && @user.authenticate(params[:session][:password])
+ sign_in @user
+ redirect_to root_path
+ else
+ format.html { render action: 'new' }
+ format.json { render json: @user.errors, status: :unprocessable_entity }
+ end
+ end
end
# DELETE /sessions/current
diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb
index a820b2f..550a54d 100644
--- a/app/views/sessions/new.html.erb
+++ b/app/views/sessions/new.html.erb
@@ -1,6 +1,6 @@
<h1>Sign in</h1>
-<% if @fail %>
- <p class="error">Email and password combination not found</p>
+<% if @user.nil? %>
+ <p class="errors"> The username or password is incorrect. Verify that CAPS LOCK is not on, and then retype the current username and password. </p>
<% end %>
<div class="row">
<div class="span6 offset3">