feat(identity): confirm registration email atomically
This commit is contained in:
1 parent
8e7ce8d71c
commit
fade4e76e4
75 files changed
+4188
-403
No files matched your search
@@ -39,6 +39,7 @@ INSERT INTO consent_records (
|
||||
text_version,
|
||||
text_hash,
|
||||
source,
|
||||
registration_version,
|
||||
granted_at
|
||||
) VALUES (
|
||||
sqlc.arg(id),
|
||||
@@ -47,6 +48,7 @@ INSERT INTO consent_records (
|
||||
sqlc.arg(text_version),
|
||||
sqlc.arg(text_hash),
|
||||
sqlc.arg(source),
|
||||
sqlc.narg(registration_version)::bigint,
|
||||
sqlc.arg(granted_at)
|
||||
)
|
||||
ON CONFLICT (subject_id, purpose, text_version)
|
||||
@@ -59,6 +61,7 @@ RETURNING
|
||||
text_version,
|
||||
text_hash,
|
||||
source,
|
||||
registration_version,
|
||||
organization_id,
|
||||
organization_name,
|
||||
field_set,
|
||||
@@ -93,6 +96,7 @@ INSERT INTO consent_records (
|
||||
text_version,
|
||||
text_hash,
|
||||
source,
|
||||
registration_version,
|
||||
organization_id,
|
||||
organization_name,
|
||||
field_set,
|
||||
@@ -106,6 +110,7 @@ INSERT INTO consent_records (
|
||||
sqlc.arg(text_version),
|
||||
sqlc.arg(text_hash),
|
||||
'invitation_acceptance',
|
||||
NULL,
|
||||
sqlc.arg(organization_id),
|
||||
sqlc.arg(organization_name),
|
||||
sqlc.arg(field_set)::text [],
|
||||
@@ -122,6 +127,7 @@ RETURNING
|
||||
text_version,
|
||||
text_hash,
|
||||
source,
|
||||
registration_version,
|
||||
organization_id,
|
||||
organization_name,
|
||||
field_set,
|
||||
@@ -140,6 +146,7 @@ SELECT
|
||||
record.text_version,
|
||||
record.text_hash,
|
||||
record.source,
|
||||
record.registration_version,
|
||||
record.organization_id,
|
||||
record.organization_name,
|
||||
record.field_set,
|
||||
@@ -177,6 +184,7 @@ SELECT
|
||||
text_version,
|
||||
text_hash,
|
||||
source,
|
||||
registration_version,
|
||||
organization_id,
|
||||
organization_name,
|
||||
field_set,
|
||||
@@ -202,6 +210,7 @@ SELECT
|
||||
text_version,
|
||||
text_hash,
|
||||
source,
|
||||
registration_version,
|
||||
organization_id,
|
||||
organization_name,
|
||||
field_set,
|
||||
@@ -220,6 +229,34 @@ WHERE
|
||||
ORDER BY granted_at DESC, id DESC
|
||||
LIMIT 1;
|
||||
|
||||
-- Locks the active registration C1 while its pending registration is applied.
|
||||
-- name: LockRegistrationConsentRecord :one
|
||||
SELECT
|
||||
id,
|
||||
subject_id,
|
||||
purpose,
|
||||
text_version,
|
||||
text_hash,
|
||||
source,
|
||||
registration_version,
|
||||
organization_id,
|
||||
organization_name,
|
||||
field_set,
|
||||
invitation_id,
|
||||
invitation_terms_version,
|
||||
granted_at,
|
||||
revoked_at,
|
||||
revocation_source,
|
||||
'active'::text AS state
|
||||
FROM consent_records
|
||||
WHERE
|
||||
subject_id = sqlc.arg(subject_id)
|
||||
AND purpose = 'c1'
|
||||
AND source = 'registration'
|
||||
AND registration_version = sqlc.arg(registration_version)
|
||||
AND revoked_at IS NULL
|
||||
FOR UPDATE;
|
||||
|
||||
-- name: ListCurrentContactConsentRecords :many
|
||||
SELECT
|
||||
id,
|
||||
@@ -228,6 +265,7 @@ SELECT
|
||||
text_version,
|
||||
text_hash,
|
||||
source,
|
||||
registration_version,
|
||||
organization_id,
|
||||
organization_name,
|
||||
field_set,
|
||||
@@ -265,6 +303,7 @@ RETURNING
|
||||
text_version,
|
||||
text_hash,
|
||||
source,
|
||||
registration_version,
|
||||
organization_id,
|
||||
organization_name,
|
||||
field_set,
|
||||
@@ -294,6 +333,7 @@ RETURNING
|
||||
text_version,
|
||||
text_hash,
|
||||
source,
|
||||
registration_version,
|
||||
organization_id,
|
||||
organization_name,
|
||||
field_set,
|
||||
@@ -320,6 +360,7 @@ WITH ledger AS (
|
||||
record.text_version,
|
||||
record.text_hash,
|
||||
record.source,
|
||||
record.registration_version,
|
||||
record.organization_id,
|
||||
record.organization_name,
|
||||
record.field_set,
|
||||
@@ -354,6 +395,7 @@ SELECT
|
||||
ledger.text_version,
|
||||
ledger.text_hash,
|
||||
ledger.source,
|
||||
ledger.registration_version,
|
||||
ledger.organization_id,
|
||||
ledger.organization_name,
|
||||
ledger.field_set,
|
||||
|
||||
Reference in new issue
Block a user