Admins that are not signed in are redirected to the signin page when doing admin actions (#964)

This commit is contained in:
Ahmad Farhat 2020-02-24 17:30:39 -05:00 committed by GitHub
parent 475374090a
commit 54234ef54b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 1 deletions

View File

@ -200,7 +200,23 @@ class ApplicationController < ActionController::Base
# Manually deal with 401 errors
rescue_from CanCan::AccessDenied do |_exception|
if current_user
render "errors/greenlight_error"
else
# Store the current url as a cookie to redirect to after sigining in
cookies[:return_to] = request.url
# Get the correct signin path
path = if allow_greenlight_accounts?
signin_path
elsif Rails.configuration.loadbalanced_configuration
omniauth_login_url(:bn_launcher)
else
signin_path
end
redirect_to path
end
end
private