Replace instructeur devise methods in app
This commit is contained in:
parent
a84e07a376
commit
c8a7bde5e0
1 changed files with 11 additions and 7 deletions
|
@ -18,6 +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
|
||||||
|
|
||||||
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) }
|
||||||
request_http_basic_authentication
|
request_http_basic_authentication
|
||||||
|
@ -42,16 +44,12 @@ class ApplicationController < ActionController::Base
|
||||||
logged_user.present?
|
logged_user.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
helper_method :logged_in?
|
|
||||||
|
|
||||||
def multiple_devise_profile_connect?
|
def multiple_devise_profile_connect?
|
||||||
user_signed_in? && instructeur_signed_in? ||
|
user_signed_in? && instructeur_signed_in? ||
|
||||||
instructeur_signed_in? && administrateur_signed_in? ||
|
instructeur_signed_in? && administrateur_signed_in? ||
|
||||||
user_signed_in? && administrateur_signed_in?
|
user_signed_in? && administrateur_signed_in?
|
||||||
end
|
end
|
||||||
|
|
||||||
helper_method :multiple_devise_profile_connect?
|
|
||||||
|
|
||||||
def pundit_user
|
def pundit_user
|
||||||
{
|
{
|
||||||
administrateur: current_administrateur,
|
administrateur: current_administrateur,
|
||||||
|
@ -60,6 +58,14 @@ class ApplicationController < ActionController::Base
|
||||||
}.compact
|
}.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def current_instructeur
|
||||||
|
current_user&.instructeur
|
||||||
|
end
|
||||||
|
|
||||||
|
def instructeur_signed_in?
|
||||||
|
user_signed_in? && current_user&.instructeur.present?
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def authenticate_logged_user!
|
def authenticate_logged_user!
|
||||||
|
@ -73,9 +79,7 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate_instructeur!
|
def authenticate_instructeur!
|
||||||
if instructeur_signed_in?
|
if !instructeur_signed_in?
|
||||||
super
|
|
||||||
else
|
|
||||||
redirect_to new_user_session_path
|
redirect_to new_user_session_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue