app/controllers/sessions_controller.rb in tkh_authentication-0.1.2 vs app/controllers/sessions_controller.rb in tkh_authentication-0.1.3

- old
+ new

@@ -1,12 +1,14 @@ class SessionsController < ApplicationController def new + redirect_to root_path if current_user end def create user = User.find_by_email(params[:email]) + set_target_page if user && user.authenticate(params[:password]) if params[:remember_me] cookies.permanent[:auth_token] = user.auth_token else cookies[:auth_token] = user.auth_token @@ -20,8 +22,14 @@ end def destroy cookies.delete(:auth_token) redirect_to safe_root_url, notice: t('authentication.logout_confirmation') + end + + private + + def set_target_page + session[:target_page] = request.referer unless session[:target_page] # && !request.referer.nil? end end