demarches-normaliennes/app/models/user.rb
Xavier J 9e0dfb593e Add FranceConnect Particulier
Reactivate FranceConnect Entreprise
2015-12-24 10:12:23 +01:00

30 lines
932 B
Ruby

class User < ActiveRecord::Base
enum loged_in_with_france_connect: {particulier: 'particulier',
entreprise: 'entreprise'}
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :dossiers
def self.find_for_france_connect_particulier user_info
User.find_by(france_connect_particulier_id: user_info[:france_connect_particulier_id])
end
def self.find_for_france_connect email, siret
user = User.find_by_email(email)
if user.nil?
return User.create(email: email, password: Devise.friendly_token[0, 20], siret: siret)
else
user.update_attributes(siret: siret)
user
end
end
def loged_in_with_france_connect?
!loged_in_with_france_connect.nil?
end
end