controllers: rename pundit_user
to current_account
It makes epxlicity what is the name of the structure returned by `pundit_user`: not an actual User, but an `account` structure.
This commit is contained in:
parent
deeab55857
commit
812aef978d
1 changed files with 11 additions and 9 deletions
|
@ -21,7 +21,7 @@ class ApplicationController < ActionController::Base
|
||||||
before_action :setup_tracking
|
before_action :setup_tracking
|
||||||
|
|
||||||
helper_method :multiple_devise_profile_connect?, :instructeur_signed_in?, :current_instructeur,
|
helper_method :multiple_devise_profile_connect?, :instructeur_signed_in?, :current_instructeur,
|
||||||
:administrateur_signed_in?, :current_administrateur
|
:administrateur_signed_in?, :current_administrateur, :current_account
|
||||||
|
|
||||||
def staging_authenticate
|
def staging_authenticate
|
||||||
if StagingAuthService.enabled? && !authenticate_with_http_basic { |username, password| StagingAuthService.authenticate(username, password) }
|
if StagingAuthService.enabled? && !authenticate_with_http_basic { |username, password| StagingAuthService.authenticate(username, password) }
|
||||||
|
@ -49,14 +49,6 @@ class ApplicationController < ActionController::Base
|
||||||
user_signed_in? && administrateur_signed_in?
|
user_signed_in? && administrateur_signed_in?
|
||||||
end
|
end
|
||||||
|
|
||||||
def pundit_user
|
|
||||||
{
|
|
||||||
administrateur: current_administrateur,
|
|
||||||
instructeur: current_instructeur,
|
|
||||||
user: current_user
|
|
||||||
}.compact
|
|
||||||
end
|
|
||||||
|
|
||||||
def current_instructeur
|
def current_instructeur
|
||||||
current_user&.instructeur
|
current_user&.instructeur
|
||||||
end
|
end
|
||||||
|
@ -73,6 +65,16 @@ class ApplicationController < ActionController::Base
|
||||||
current_administrateur.present?
|
current_administrateur.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def current_account
|
||||||
|
{
|
||||||
|
administrateur: current_administrateur,
|
||||||
|
instructeur: current_instructeur,
|
||||||
|
user: current_user
|
||||||
|
}.compact
|
||||||
|
end
|
||||||
|
|
||||||
|
alias_method :pundit_user, :current_account
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def feature_enabled?(feature_name)
|
def feature_enabled?(feature_name)
|
||||||
|
|
Loading…
Add table
Reference in a new issue