Replace administrateur devise methods in app
This commit is contained in:
parent
840be2408e
commit
4142acf8d3
1 changed files with 11 additions and 4 deletions
|
@ -18,7 +18,8 @@ class ApplicationController < ActionController::Base
|
||||||
before_action :set_active_storage_host
|
before_action :set_active_storage_host
|
||||||
before_action :setup_tracking
|
before_action :setup_tracking
|
||||||
|
|
||||||
helper_method :logged_in?, :multiple_devise_profile_connect?, :instructeur_signed_in?, :current_instructeur
|
helper_method :logged_in?, :multiple_devise_profile_connect?, :instructeur_signed_in?, :current_instructeur,
|
||||||
|
:administrateur_signed_in?, :current_administrateur
|
||||||
|
|
||||||
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) }
|
||||||
|
@ -66,6 +67,14 @@ class ApplicationController < ActionController::Base
|
||||||
user_signed_in? && current_user&.instructeur.present?
|
user_signed_in? && current_user&.instructeur.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def current_administrateur
|
||||||
|
current_user&.administrateur
|
||||||
|
end
|
||||||
|
|
||||||
|
def administrateur_signed_in?
|
||||||
|
current_administrateur.present?
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def authenticate_logged_user!
|
def authenticate_logged_user!
|
||||||
|
@ -85,9 +94,7 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate_administrateur!
|
def authenticate_administrateur!
|
||||||
if administrateur_signed_in?
|
if !administrateur_signed_in?
|
||||||
super
|
|
||||||
else
|
|
||||||
redirect_to new_user_session_path
|
redirect_to new_user_session_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue