diff options
author | guntasgrewal <guntasgrewal@gmail.com> | 2014-03-04 17:58:18 -0500 |
---|---|---|
committer | guntasgrewal <guntasgrewal@gmail.com> | 2014-03-04 17:58:18 -0500 |
commit | e587dc3fab34724d06eceb042c6e9eed6a7d95f4 (patch) | |
tree | 051b58b2f9e22b305068a58a3b059e49e3b2fbf9 /app/controllers | |
parent | d2b1f26cf41c6e1f887069c6c31bf3677416b993 (diff) | |
parent | c6ba6c11c7f0665064efdfc9385a5b8e1deaee50 (diff) |
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/sessions_controller.rb | 19 |
1 files changed, 10 insertions, 9 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 |