diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/sessions_controller.rb | 17 | ||||
-rw-r--r-- | app/controllers/users_controller.rb | 2 |
2 files changed, 11 insertions, 8 deletions
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 68cb949..3417332 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,22 +1,25 @@ class SessionsController < ApplicationController def new + if @user.nil? + @user = User.new + end end # find the user and create a new session def create - user = User.find_by(email: params[:session][:email].downcase) - if user && user.authenticate(params[:session][:password]) - sign_in user + @user = User.find_by(email: params[:session][:email].downcase) + if @user && @user.authenticate(params[:session][:password]) + sign_in @user redirect_to root_path else - render 'new' - end + redirect_to signin_path + end end def destroy - sign_out - redirect_to root_path + sign_out + redirect_to root_path end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f540dde..284892b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -10,7 +10,7 @@ class UsersController < ApplicationController # GET /users/1 # GET /users/1.json def show - @user = User.find(param[:id]) + @user = User.find(params[:id]) end # GET /users/new |