readapt name and logic
This commit is contained in:
parent
94be599401
commit
eaef5c7e39
14 changed files with 210 additions and 512 deletions
|
@ -8,7 +8,7 @@ class FranceConnectInformation < ApplicationRecord
|
|||
|
||||
validates :france_connect_particulier_id, presence: true, allow_blank: false, allow_nil: false
|
||||
|
||||
def associate_user!(email)
|
||||
def safely_associate_user!(email)
|
||||
begin
|
||||
user = User.create!(
|
||||
email: email.downcase,
|
||||
|
@ -22,11 +22,18 @@ class FranceConnectInformation < ApplicationRecord
|
|||
# because the first call has already created a user
|
||||
end
|
||||
|
||||
clean_tokens_and_requested_email
|
||||
update_attribute('user_id', user.id)
|
||||
touch # needed to update updated_at column
|
||||
save!
|
||||
end
|
||||
|
||||
def send_custom_confirmation_instructions(user)
|
||||
def safely_update_user(user:)
|
||||
self.user = user
|
||||
clean_tokens_and_requested_email
|
||||
save!
|
||||
end
|
||||
|
||||
def send_custom_confirmation_instructions
|
||||
token = SecureRandom.hex(10)
|
||||
user.update!(confirmation_token: token, confirmation_sent_at: Time.zone.now)
|
||||
UserMailer.custom_confirmation_instructions(user, token).deliver_later
|
||||
|
@ -54,14 +61,18 @@ class FranceConnectInformation < ApplicationRecord
|
|||
(MERGE_VALIDITY.ago < email_merge_token_created_at) && user_id.nil?
|
||||
end
|
||||
|
||||
def delete_merge_token!
|
||||
update(merge_token: nil, merge_token_created_at: nil)
|
||||
end
|
||||
|
||||
def delete_email_merge_token!
|
||||
update(email_merge_token: nil, email_merge_token_created_at: nil)
|
||||
end
|
||||
|
||||
def clean_tokens_and_requested_email
|
||||
self.merge_token = nil
|
||||
self.merge_token_created_at = nil
|
||||
self.email_merge_token = nil
|
||||
self.email_merge_token_created_at = nil
|
||||
self.requested_email = nil
|
||||
end
|
||||
|
||||
def full_name
|
||||
[given_name, family_name].compact.join(" ")
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue