add email_merge_token to france connect information
This commit is contained in:
parent
65aa07ecbe
commit
90f145e17a
3 changed files with 29 additions and 1 deletions
|
@ -31,14 +31,29 @@ class FranceConnectInformation < ApplicationRecord
|
|||
merge_token
|
||||
end
|
||||
|
||||
def create_email_merge_token!
|
||||
email_merge_token = SecureRandom.uuid
|
||||
update(email_merge_token:, email_merge_token_created_at: Time.zone.now)
|
||||
|
||||
email_merge_token
|
||||
end
|
||||
|
||||
def valid_for_merge?
|
||||
(MERGE_VALIDITY.ago < merge_token_created_at) && user_id.nil?
|
||||
end
|
||||
|
||||
def valid_for_email_merge?
|
||||
(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 full_name
|
||||
[given_name, family_name].compact.join(" ")
|
||||
end
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
class AddEmailMergeTokenColumnToFranceConnectInformation < ActiveRecord::Migration[7.0]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
add_column :france_connect_informations, :email_merge_token, :string
|
||||
add_column :france_connect_informations, :email_merge_token_created_at, :datetime
|
||||
|
||||
add_index :france_connect_informations, :email_merge_token, algorithm: :concurrently
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_12_21_142727) do
|
||||
ActiveRecord::Schema[7.0].define(version: 2024_01_10_113623) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pgcrypto"
|
||||
enable_extension "plpgsql"
|
||||
|
@ -626,6 +626,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_12_21_142727) do
|
|||
t.datetime "created_at", precision: nil, null: false
|
||||
t.jsonb "data"
|
||||
t.string "email_france_connect"
|
||||
t.string "email_merge_token"
|
||||
t.datetime "email_merge_token_created_at"
|
||||
t.string "family_name"
|
||||
t.string "france_connect_particulier_id"
|
||||
t.string "gender"
|
||||
|
@ -634,6 +636,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_12_21_142727) do
|
|||
t.datetime "merge_token_created_at", precision: nil
|
||||
t.datetime "updated_at", precision: nil, null: false
|
||||
t.integer "user_id"
|
||||
t.index ["email_merge_token"], name: "index_france_connect_informations_on_email_merge_token"
|
||||
t.index ["merge_token"], name: "index_france_connect_informations_on_merge_token"
|
||||
t.index ["user_id"], name: "index_france_connect_informations_on_user_id"
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue