demarches-normaliennes/app/services/switch_devise_profile_service.rb

26 lines
589 B
Ruby
Raw Normal View History

class SwitchDeviseProfileService
def initialize(warden)
@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?
end
def gestionnaire_signed_in?
2018-01-11 19:08:04 +01:00
@warden.authenticate(:scope => :gestionnaire).present?
end
def administrateur_signed_in?
2018-01-11 19:08:04 +01:00
@warden.authenticate(:scope => :administrateur).present?
end
2017-04-04 15:27:04 +02:00
end