2016-12-07 18:00:27 +01:00
|
|
|
class SwitchDeviseProfileService
|
2018-03-20 17:47:37 +01:00
|
|
|
def initialize(warden)
|
2016-12-07 18:00:27 +01:00
|
|
|
@warden = warden
|
|
|
|
end
|
|
|
|
|
|
|
|
def multiple_devise_profile_connect?
|
2019-08-06 11:02:54 +02:00
|
|
|
user_signed_in? && instructeur_signed_in? ||
|
|
|
|
instructeur_signed_in? && administrateur_signed_in? ||
|
2016-12-07 18:00:27 +01:00
|
|
|
user_signed_in? && administrateur_signed_in?
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def user_signed_in?
|
2018-01-11 19:08:04 +01:00
|
|
|
@warden.authenticate(:scope => :user).present?
|
2016-12-07 18:00:27 +01:00
|
|
|
end
|
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
def instructeur_signed_in?
|
|
|
|
@warden.authenticate(:scope => :instructeur).present?
|
2016-12-07 18:00:27 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def administrateur_signed_in?
|
2018-01-11 19:08:04 +01:00
|
|
|
@warden.authenticate(:scope => :administrateur).present?
|
2016-12-07 18:00:27 +01:00
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|