app/controllers/users_controller.rb in tkh_authentication-0.1.2 vs app/controllers/users_controller.rb in tkh_authentication-0.1.3
- old
+ new
@@ -12,12 +12,13 @@
@user = User.new
end
def create
@user = User.new(params[:user])
+ set_target_page
if @user.save
- cookies[:auth_token] = @user.auth_token
+ cookies[:auth_token] = @user.auth_token # logging in the user
redirect_to session[:target_page] || safe_root_url, notice: t('authentication.signup_confirmation')
session[:target_page] = nil
else
render "new"
end
@@ -33,8 +34,14 @@
def remove_admin
user = User.find(params[:id])
user.admin = false
user.save
redirect_to users_path, notice: t('authentication.admin_disabled_confirmation')
+ end
+
+ private
+
+ def set_target_page
+ session[:target_page] = request.referer unless session[:target_page] # && !request.referer.nil?
end
end