Skip to content

Commit

Permalink
sessions controller changes for reek
Browse files Browse the repository at this point in the history
  • Loading branch information
Elise Worthy committed Apr 19, 2012
1 parent baf02fb commit 2e224ab
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@ def new
end

def create
cart_id = current_cart.id
user = login(params[:email], params[:password])
if user
session[:cart_id] = cart_id
set_cart_and_user
if @user
session[:cart_id] = @cart_id
redirect_to cart_path(current_cart), :notice => "Logged in!"
else
flash.now.notice = "Email or password was invalid"
render :new
end
end

def set_cart_and_user
@cart_id = current_cart.id
@user = login(params[:email], params[:password])
end

def destroy
logout
redirect_to root_url, :notice => "Logged out!"
Expand Down

0 comments on commit 2e224ab

Please sign in to comment.