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?
|
|
|
|
user_signed_in? && gestionnaire_signed_in? ||
|
|
|
|
gestionnaire_signed_in? && administrateur_signed_in? ||
|
|
|
|
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
|
|
|
|
|
|
|
|
def gestionnaire_signed_in?
|
2018-01-11 19:08:04 +01:00
|
|
|
@warden.authenticate(:scope => :gestionnaire).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
|