2020-08-06 16:35:45 +02:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: france_connect_informations
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
|
|
|
# birthdate :date
|
|
|
|
# birthplace :string
|
|
|
|
# email_france_connect :string
|
|
|
|
# family_name :string
|
|
|
|
# gender :string
|
|
|
|
# given_name :string
|
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
|
|
|
# france_connect_particulier_id :string
|
|
|
|
# user_id :integer
|
|
|
|
#
|
2018-03-06 13:44:29 +01:00
|
|
|
class FranceConnectInformation < ApplicationRecord
|
2020-07-20 16:06:03 +02:00
|
|
|
belongs_to :user, optional: true
|
2016-01-21 17:06:09 +01:00
|
|
|
|
|
|
|
validates :france_connect_particulier_id, presence: true, allow_blank: false, allow_nil: false
|
2021-02-01 14:28:04 +01:00
|
|
|
|
|
|
|
def associate_user!
|
|
|
|
user = User.find_by(email: email_france_connect.downcase)
|
|
|
|
|
|
|
|
if user.nil?
|
|
|
|
user = User.create!(
|
|
|
|
email: email_france_connect.downcase,
|
|
|
|
password: Devise.friendly_token[0, 20],
|
|
|
|
confirmed_at: Time.zone.now
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
update_attribute('user_id', user.id)
|
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|