feat(identity): confirm the email address with a six-digit code from the message
This commit is contained in:
1 parent
c94434cd09
commit
d365a05c96
87 files changed
+4764
-224
No files matched your search
@@ -395,7 +395,7 @@ func (repository emailTokenRepository) FindByHash(
|
||||
if owner.RegistrationVersion != row.RegistrationVersion {
|
||||
return domain.EmailToken{}, fmt.Errorf("%s - token belongs to an earlier registration: %w", location, outbound.ErrEmailTokenInvalidated)
|
||||
}
|
||||
return emailTokenFromRow(row)
|
||||
return emailTokenFromRow(emailTokenModelFromHashRow(row))
|
||||
}
|
||||
|
||||
func (repository emailTokenRepository) Insert(ctx context.Context, token domain.EmailToken) error {
|
||||
@@ -411,6 +411,10 @@ func (repository emailTokenRepository) Insert(ctx context.Context, token domain.
|
||||
CreatedAt: pgTime(token.CreatedAt),
|
||||
ExpiresAt: pgTime(token.ExpiresAt),
|
||||
}
|
||||
if code := token.Code; code != nil {
|
||||
params.CodeHash = code.Hash[:]
|
||||
params.CodeExpiresAt = pgTime(code.ExpiresAt)
|
||||
}
|
||||
if pending := token.Pending; pending != nil {
|
||||
params.PendingPasswordHash = pgtype.Text{String: pending.PasswordHash.PHC(), Valid: true}
|
||||
params.PendingScenario = pgtype.Text{String: string(pending.Scenario), Valid: true}
|
||||
@@ -501,7 +505,7 @@ func (repository emailTokenRepository) Consume(
|
||||
ConsumedAt: pgTime(at),
|
||||
})
|
||||
if err == nil {
|
||||
return emailTokenFromRow(sqlc.EmailToken(row))
|
||||
return emailTokenFromRow(consumedEmailTokenRow(row))
|
||||
}
|
||||
if !errors.Is(err, pgx.ErrNoRows) {
|
||||
return domain.EmailToken{}, fmt.Errorf("emailTokenRepository.Consume - update email token: %w", mapIdentityError(err))
|
||||
@@ -512,6 +516,84 @@ func (repository emailTokenRepository) Consume(
|
||||
return domain.EmailToken{}, errors.New("emailTokenRepository.Consume - token became consumable after a failed attempt")
|
||||
}
|
||||
|
||||
// emailTokenModelFromHashRow maps the row of GetEmailTokenByHash, which selects
|
||||
// the token by its hash, to the table model.
|
||||
func emailTokenModelFromHashRow(row sqlc.GetEmailTokenByHashRow) sqlc.EmailToken {
|
||||
return sqlc.EmailToken{
|
||||
ID: row.ID,
|
||||
UserID: row.UserID,
|
||||
Purpose: row.Purpose,
|
||||
TokenHash: row.TokenHash,
|
||||
RegistrationVersion: row.RegistrationVersion,
|
||||
CreatedAt: row.CreatedAt,
|
||||
ExpiresAt: row.ExpiresAt,
|
||||
ConsumedAt: row.ConsumedAt,
|
||||
InvalidatedAt: row.InvalidatedAt,
|
||||
CodeHash: row.CodeHash,
|
||||
CodeExpiresAt: row.CodeExpiresAt,
|
||||
CodeFailedAttempts: row.CodeFailedAttempts,
|
||||
PendingPasswordHash: row.PendingPasswordHash,
|
||||
PendingScenario: row.PendingScenario,
|
||||
PendingOnboardingStep: row.PendingOnboardingStep,
|
||||
}
|
||||
}
|
||||
|
||||
// emailTokenModelFromOpenCodeRow maps the row of GetOpenEmailCodeByAddress to
|
||||
// the table model. The columns are the same as in GetEmailTokenByHash.
|
||||
func emailTokenModelFromOpenCodeRow(row sqlc.GetOpenEmailCodeByAddressRow) sqlc.EmailToken {
|
||||
return sqlc.EmailToken{
|
||||
ID: row.ID,
|
||||
UserID: row.UserID,
|
||||
Purpose: row.Purpose,
|
||||
TokenHash: row.TokenHash,
|
||||
RegistrationVersion: row.RegistrationVersion,
|
||||
CreatedAt: row.CreatedAt,
|
||||
ExpiresAt: row.ExpiresAt,
|
||||
ConsumedAt: row.ConsumedAt,
|
||||
InvalidatedAt: row.InvalidatedAt,
|
||||
CodeHash: row.CodeHash,
|
||||
CodeExpiresAt: row.CodeExpiresAt,
|
||||
CodeFailedAttempts: row.CodeFailedAttempts,
|
||||
PendingPasswordHash: row.PendingPasswordHash,
|
||||
PendingScenario: row.PendingScenario,
|
||||
PendingOnboardingStep: row.PendingOnboardingStep,
|
||||
}
|
||||
}
|
||||
|
||||
// consumedEmailTokenRow maps the row of ConsumeEmailToken, which holds the token
|
||||
// as it was before the update, to the table model. The update clears the code,
|
||||
// so the returned row has none to map.
|
||||
func consumedEmailTokenRow(row sqlc.ConsumeEmailTokenRow) sqlc.EmailToken {
|
||||
return sqlc.EmailToken{
|
||||
ID: row.ID,
|
||||
UserID: row.UserID,
|
||||
Purpose: row.Purpose,
|
||||
TokenHash: row.TokenHash,
|
||||
RegistrationVersion: row.RegistrationVersion,
|
||||
CreatedAt: row.CreatedAt,
|
||||
ExpiresAt: row.ExpiresAt,
|
||||
ConsumedAt: row.ConsumedAt,
|
||||
InvalidatedAt: row.InvalidatedAt,
|
||||
PendingPasswordHash: row.PendingPasswordHash,
|
||||
PendingScenario: row.PendingScenario,
|
||||
PendingOnboardingStep: row.PendingOnboardingStep,
|
||||
}
|
||||
}
|
||||
|
||||
// emailCodeFromColumns decodes the code state of a token row. A NULL digest
|
||||
// means the token carries no code.
|
||||
func emailCodeFromColumns(digest []byte, expiresAt pgtype.Timestamptz) (*domain.EmailCode, error) {
|
||||
if len(digest) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
var hash domain.VerificationCodeHash
|
||||
if len(digest) != len(hash) || !expiresAt.Valid {
|
||||
return nil, errors.New("postgres.emailCodeFromColumns - stored code state is incomplete")
|
||||
}
|
||||
copy(hash[:], digest)
|
||||
return &domain.EmailCode{Hash: hash, ExpiresAt: expiresAt.Time}, nil
|
||||
}
|
||||
|
||||
// explainUnconsumable classifies a token that the atomic consume did not
|
||||
// match. A nil result means the token is consumable again, which only a
|
||||
// concurrent transaction that changed and then rolled back the row can cause.
|
||||
@@ -540,6 +622,43 @@ func (repository emailTokenRepository) explainUnconsumable(
|
||||
}
|
||||
}
|
||||
|
||||
// FindOpenCodeByAddress reads the newest open token with a code of the
|
||||
// unverified account at the address. The account is found by the normalized
|
||||
// address; the code itself is compared by the usecase.
|
||||
func (repository emailTokenRepository) FindOpenCodeByAddress(ctx context.Context, email domain.EmailAddress) (domain.EmailToken, error) {
|
||||
const location = "emailTokenRepository.FindOpenCodeByAddress"
|
||||
row, err := repository.queries.GetOpenEmailCodeByAddress(ctx, sqlc.GetOpenEmailCodeByAddressParams{
|
||||
EmailNormalized: email.Normalized(),
|
||||
Purpose: string(domain.EmailTokenPurposeEmailVerification),
|
||||
})
|
||||
if err != nil {
|
||||
return domain.EmailToken{}, fmt.Errorf("%s - select open code: %w", location, mapNoRows(err, outbound.ErrEmailTokenNotFound))
|
||||
}
|
||||
return emailTokenFromRow(emailTokenModelFromOpenCodeRow(row))
|
||||
}
|
||||
|
||||
// RecordFailedCodeAttempt counts a failed attempt in one statement. A token
|
||||
// that is no longer open matches no row, which is not an error: the attempt
|
||||
// then counts nothing, and the caller refuses the request either way.
|
||||
func (repository emailTokenRepository) RecordFailedCodeAttempt(ctx context.Context, id uuid.UUID, at time.Time) (bool, error) {
|
||||
const location = "emailTokenRepository.RecordFailedCodeAttempt"
|
||||
if err := requireTime(location, at, domain.ErrInvalidEmailToken); err != nil {
|
||||
return false, err
|
||||
}
|
||||
burned, err := repository.queries.RecordFailedEmailCodeAttempt(ctx, sqlc.RecordFailedEmailCodeAttemptParams{
|
||||
MaxAttempts: domain.VerificationCodeMaxFailedAttempts,
|
||||
AttemptedAt: pgTime(at),
|
||||
ID: pgUUID(id),
|
||||
})
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return false, nil
|
||||
}
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("%s - count failed attempt: %w", location, mapIdentityError(err))
|
||||
}
|
||||
return burned, nil
|
||||
}
|
||||
|
||||
func emailTokenFromRow(row sqlc.EmailToken) (domain.EmailToken, error) {
|
||||
purpose, err := domain.ParseEmailTokenPurpose(row.Purpose)
|
||||
if err != nil {
|
||||
@@ -553,8 +672,13 @@ func emailTokenFromRow(row sqlc.EmailToken) (domain.EmailToken, error) {
|
||||
if err != nil {
|
||||
return domain.EmailToken{}, err
|
||||
}
|
||||
code, err := emailCodeFromColumns(row.CodeHash, row.CodeExpiresAt)
|
||||
if err != nil {
|
||||
return domain.EmailToken{}, err
|
||||
}
|
||||
return domain.EmailToken{
|
||||
Pending: pending,
|
||||
Code: code,
|
||||
ID: uuid.UUID(row.ID.Bytes),
|
||||
UserID: uuid.UUID(row.UserID.Bytes),
|
||||
Purpose: purpose,
|
||||
|
||||
@@ -207,7 +207,9 @@ consumed AS (
|
||||
consumed_at = $3,
|
||||
pending_password_hash = NULL,
|
||||
pending_scenario = NULL,
|
||||
pending_onboarding_step = NULL
|
||||
pending_onboarding_step = NULL,
|
||||
code_hash = NULL,
|
||||
code_expires_at = NULL
|
||||
FROM candidate
|
||||
WHERE token.id = candidate.id
|
||||
RETURNING token.id, token.consumed_at, token.invalidated_at
|
||||
@@ -459,6 +461,9 @@ SELECT
|
||||
expires_at,
|
||||
consumed_at,
|
||||
invalidated_at,
|
||||
code_hash,
|
||||
code_expires_at,
|
||||
code_failed_attempts,
|
||||
pending_password_hash,
|
||||
pending_scenario,
|
||||
pending_onboarding_step
|
||||
@@ -472,11 +477,29 @@ type GetEmailTokenByHashParams struct {
|
||||
Purpose string
|
||||
}
|
||||
|
||||
type GetEmailTokenByHashRow struct {
|
||||
ID pgtype.UUID
|
||||
UserID pgtype.UUID
|
||||
Purpose string
|
||||
TokenHash []byte
|
||||
RegistrationVersion int64
|
||||
CreatedAt pgtype.Timestamptz
|
||||
ExpiresAt pgtype.Timestamptz
|
||||
ConsumedAt pgtype.Timestamptz
|
||||
InvalidatedAt pgtype.Timestamptz
|
||||
CodeHash []byte
|
||||
CodeExpiresAt pgtype.Timestamptz
|
||||
CodeFailedAttempts int16
|
||||
PendingPasswordHash pgtype.Text
|
||||
PendingScenario pgtype.Text
|
||||
PendingOnboardingStep pgtype.Text
|
||||
}
|
||||
|
||||
// Reads a token before password verification; Consume rechecks it in the
|
||||
// confirmation transaction and clears pending credentials when it succeeds.
|
||||
func (q *Queries) GetEmailTokenByHash(ctx context.Context, arg GetEmailTokenByHashParams) (EmailToken, error) {
|
||||
func (q *Queries) GetEmailTokenByHash(ctx context.Context, arg GetEmailTokenByHashParams) (GetEmailTokenByHashRow, error) {
|
||||
row := q.db.QueryRow(ctx, getEmailTokenByHash, arg.TokenHash, arg.Purpose)
|
||||
var i EmailToken
|
||||
var i GetEmailTokenByHashRow
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.UserID,
|
||||
@@ -487,6 +510,9 @@ func (q *Queries) GetEmailTokenByHash(ctx context.Context, arg GetEmailTokenByHa
|
||||
&i.ExpiresAt,
|
||||
&i.ConsumedAt,
|
||||
&i.InvalidatedAt,
|
||||
&i.CodeHash,
|
||||
&i.CodeExpiresAt,
|
||||
&i.CodeFailedAttempts,
|
||||
&i.PendingPasswordHash,
|
||||
&i.PendingScenario,
|
||||
&i.PendingOnboardingStep,
|
||||
@@ -597,6 +623,88 @@ func (q *Queries) GetLiveIdempotencyRecord(ctx context.Context, arg GetLiveIdemp
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getOpenEmailCodeByAddress = `-- name: GetOpenEmailCodeByAddress :one
|
||||
SELECT
|
||||
token.id,
|
||||
token.user_id,
|
||||
token.purpose,
|
||||
token.token_hash,
|
||||
token.registration_version,
|
||||
token.created_at,
|
||||
token.expires_at,
|
||||
token.consumed_at,
|
||||
token.invalidated_at,
|
||||
token.code_hash,
|
||||
token.code_expires_at,
|
||||
token.code_failed_attempts,
|
||||
token.pending_password_hash,
|
||||
token.pending_scenario,
|
||||
token.pending_onboarding_step
|
||||
FROM email_tokens AS token
|
||||
INNER JOIN users AS owner ON owner.id = token.user_id
|
||||
WHERE
|
||||
owner.email_normalized = $1
|
||||
AND owner.email_verified_at IS NULL
|
||||
AND owner.registration_version = token.registration_version
|
||||
AND token.purpose = $2
|
||||
AND token.consumed_at IS NULL
|
||||
AND token.invalidated_at IS NULL
|
||||
AND token.code_hash IS NOT NULL
|
||||
AND token.pending_password_hash IS NOT NULL
|
||||
ORDER BY token.created_at DESC, token.id DESC
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
type GetOpenEmailCodeByAddressParams struct {
|
||||
EmailNormalized string
|
||||
Purpose string
|
||||
}
|
||||
|
||||
type GetOpenEmailCodeByAddressRow struct {
|
||||
ID pgtype.UUID
|
||||
UserID pgtype.UUID
|
||||
Purpose string
|
||||
TokenHash []byte
|
||||
RegistrationVersion int64
|
||||
CreatedAt pgtype.Timestamptz
|
||||
ExpiresAt pgtype.Timestamptz
|
||||
ConsumedAt pgtype.Timestamptz
|
||||
InvalidatedAt pgtype.Timestamptz
|
||||
CodeHash []byte
|
||||
CodeExpiresAt pgtype.Timestamptz
|
||||
CodeFailedAttempts int16
|
||||
PendingPasswordHash pgtype.Text
|
||||
PendingScenario pgtype.Text
|
||||
PendingOnboardingStep pgtype.Text
|
||||
}
|
||||
|
||||
// Reads the newest open verification token that carries a code for the
|
||||
// unverified account with this normalized address. The registration version
|
||||
// must be current, so a code of an earlier registration never matches. The
|
||||
// row is read before the code is compared; the consumption rechecks it.
|
||||
func (q *Queries) GetOpenEmailCodeByAddress(ctx context.Context, arg GetOpenEmailCodeByAddressParams) (GetOpenEmailCodeByAddressRow, error) {
|
||||
row := q.db.QueryRow(ctx, getOpenEmailCodeByAddress, arg.EmailNormalized, arg.Purpose)
|
||||
var i GetOpenEmailCodeByAddressRow
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.UserID,
|
||||
&i.Purpose,
|
||||
&i.TokenHash,
|
||||
&i.RegistrationVersion,
|
||||
&i.CreatedAt,
|
||||
&i.ExpiresAt,
|
||||
&i.ConsumedAt,
|
||||
&i.InvalidatedAt,
|
||||
&i.CodeHash,
|
||||
&i.CodeExpiresAt,
|
||||
&i.CodeFailedAttempts,
|
||||
&i.PendingPasswordHash,
|
||||
&i.PendingScenario,
|
||||
&i.PendingOnboardingStep,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUserByEmailNormalized = `-- name: GetUserByEmailNormalized :one
|
||||
SELECT
|
||||
id,
|
||||
@@ -682,6 +790,8 @@ INSERT INTO email_tokens (
|
||||
registration_version,
|
||||
created_at,
|
||||
expires_at,
|
||||
code_hash,
|
||||
code_expires_at,
|
||||
pending_password_hash,
|
||||
pending_scenario,
|
||||
pending_onboarding_step
|
||||
@@ -695,7 +805,9 @@ INSERT INTO email_tokens (
|
||||
$7,
|
||||
$8,
|
||||
$9,
|
||||
$10
|
||||
$10,
|
||||
$11,
|
||||
$12
|
||||
)
|
||||
`
|
||||
|
||||
@@ -707,6 +819,8 @@ type InsertEmailTokenParams struct {
|
||||
RegistrationVersion int64
|
||||
CreatedAt pgtype.Timestamptz
|
||||
ExpiresAt pgtype.Timestamptz
|
||||
CodeHash []byte
|
||||
CodeExpiresAt pgtype.Timestamptz
|
||||
PendingPasswordHash pgtype.Text
|
||||
PendingScenario pgtype.Text
|
||||
PendingOnboardingStep pgtype.Text
|
||||
@@ -721,6 +835,8 @@ func (q *Queries) InsertEmailToken(ctx context.Context, arg InsertEmailTokenPara
|
||||
arg.RegistrationVersion,
|
||||
arg.CreatedAt,
|
||||
arg.ExpiresAt,
|
||||
arg.CodeHash,
|
||||
arg.CodeExpiresAt,
|
||||
arg.PendingPasswordHash,
|
||||
arg.PendingScenario,
|
||||
arg.PendingOnboardingStep,
|
||||
@@ -834,10 +950,12 @@ const invalidateActiveEmailTokens = `-- name: InvalidateActiveEmailTokens :execr
|
||||
UPDATE email_tokens
|
||||
SET
|
||||
invalidated_at = $1,
|
||||
-- An invalidated token keeps no password hash: it can never be confirmed.
|
||||
-- An invalidated token keeps no password hash or code: it can never be confirmed.
|
||||
pending_password_hash = NULL,
|
||||
pending_scenario = NULL,
|
||||
pending_onboarding_step = NULL
|
||||
pending_onboarding_step = NULL,
|
||||
code_hash = NULL,
|
||||
code_expires_at = NULL
|
||||
WHERE
|
||||
user_id = $2
|
||||
AND purpose = $3
|
||||
@@ -939,6 +1057,62 @@ func (q *Queries) PurgeExpiredIdempotencyRecords(ctx context.Context, arg PurgeE
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
const recordFailedEmailCodeAttempt = `-- name: RecordFailedEmailCodeAttempt :one
|
||||
UPDATE email_tokens
|
||||
SET
|
||||
code_failed_attempts = code_failed_attempts + 1,
|
||||
invalidated_at = CASE
|
||||
WHEN code_failed_attempts + 1 >= $1 THEN $2
|
||||
ELSE invalidated_at
|
||||
END,
|
||||
code_hash = CASE
|
||||
WHEN code_failed_attempts + 1 >= $1 THEN NULL
|
||||
ELSE code_hash
|
||||
END,
|
||||
code_expires_at = CASE
|
||||
WHEN code_failed_attempts + 1 >= $1 THEN NULL
|
||||
ELSE code_expires_at
|
||||
END,
|
||||
pending_password_hash = CASE
|
||||
WHEN code_failed_attempts + 1 >= $1 THEN NULL
|
||||
ELSE pending_password_hash
|
||||
END,
|
||||
pending_scenario = CASE
|
||||
WHEN code_failed_attempts + 1 >= $1 THEN NULL
|
||||
ELSE pending_scenario
|
||||
END,
|
||||
pending_onboarding_step = CASE
|
||||
WHEN code_failed_attempts + 1 >= $1 THEN NULL
|
||||
ELSE pending_onboarding_step
|
||||
END
|
||||
WHERE
|
||||
id = $3
|
||||
AND consumed_at IS NULL
|
||||
AND invalidated_at IS NULL
|
||||
AND code_hash IS NOT NULL
|
||||
AND code_failed_attempts < $1
|
||||
RETURNING code_failed_attempts >= $1 AS burned
|
||||
`
|
||||
|
||||
type RecordFailedEmailCodeAttemptParams struct {
|
||||
MaxAttempts int16
|
||||
AttemptedAt pgtype.Timestamptz
|
||||
ID pgtype.UUID
|
||||
}
|
||||
|
||||
// Counts one failed code or password attempt against an open code. The
|
||||
// single UPDATE reads and writes the counter under the row lock, so concurrent
|
||||
// failures serialize and none is lost. The attempt that reaches the limit
|
||||
// invalidates the token and drops its code and pending credentials, so the
|
||||
// code and the link both stop working. A token that is no longer open matches
|
||||
// no row and is left unchanged.
|
||||
func (q *Queries) RecordFailedEmailCodeAttempt(ctx context.Context, arg RecordFailedEmailCodeAttemptParams) (bool, error) {
|
||||
row := q.db.QueryRow(ctx, recordFailedEmailCodeAttempt, arg.MaxAttempts, arg.AttemptedAt, arg.ID)
|
||||
var burned bool
|
||||
err := row.Scan(&burned)
|
||||
return burned, err
|
||||
}
|
||||
|
||||
const reserveIdempotencyRecord = `-- name: ReserveIdempotencyRecord :one
|
||||
INSERT INTO idempotency_records (
|
||||
scope_hash,
|
||||
|
||||
@@ -581,6 +581,12 @@ type EmailToken struct {
|
||||
PendingPasswordHash pgtype.Text
|
||||
PendingScenario pgtype.Text
|
||||
PendingOnboardingStep pgtype.Text
|
||||
// HMAC-SHA-256 of the six-digit verification code under a server-side key; NULL when the token carries no code or the code has ended. The code itself is never stored.
|
||||
CodeHash []byte
|
||||
// End of the code validity: the earlier of the token expiry and the code lifetime. NULL together with code_hash.
|
||||
CodeExpiresAt pgtype.Timestamptz
|
||||
// Wrong code or password attempts counted against the open code; the token is invalidated when the count reaches the limit of five.
|
||||
CodeFailedAttempts int16
|
||||
}
|
||||
|
||||
type Holding struct {
|
||||
|
||||
@@ -345,7 +345,7 @@ type Querier interface {
|
||||
GetEffectivePolicyVersion(ctx context.Context, arg GetEffectivePolicyVersionParams) (PolicyVersion, error)
|
||||
// Reads a token before password verification; Consume rechecks it in the
|
||||
// confirmation transaction and clears pending credentials when it succeeds.
|
||||
GetEmailTokenByHash(ctx context.Context, arg GetEmailTokenByHashParams) (EmailToken, error)
|
||||
GetEmailTokenByHash(ctx context.Context, arg GetEmailTokenByHashParams) (GetEmailTokenByHashRow, error)
|
||||
// Explains why ConsumeEmailToken matched no row.
|
||||
GetEmailTokenState(ctx context.Context, arg GetEmailTokenStateParams) (GetEmailTokenStateRow, error)
|
||||
GetHoldingIDByFounder(ctx context.Context, founderAccountID pgtype.UUID) (pgtype.UUID, error)
|
||||
@@ -390,6 +390,11 @@ type Querier interface {
|
||||
// employer sees it only while they are an active member. No row means the
|
||||
// content is no longer visible to this recipient.
|
||||
GetNotificationOrganizationNameForRecipient(ctx context.Context, arg GetNotificationOrganizationNameForRecipientParams) (string, error)
|
||||
// Reads the newest open verification token that carries a code for the
|
||||
// unverified account with this normalized address. The registration version
|
||||
// must be current, so a code of an earlier registration never matches. The
|
||||
// row is read before the code is compared; the consumption rechecks it.
|
||||
GetOpenEmailCodeByAddress(ctx context.Context, arg GetOpenEmailCodeByAddressParams) (GetOpenEmailCodeByAddressRow, error)
|
||||
// Reads only the historical result. It intentionally does not join the live
|
||||
// organization or membership, whose profile and state may have since changed.
|
||||
GetOrganizationCreationResult(ctx context.Context, scopeHash []byte) ([]byte, error)
|
||||
@@ -1043,6 +1048,13 @@ type Querier interface {
|
||||
// the delivery is no longer pending or waiting, or another worker holds it.
|
||||
// now is the application clock.
|
||||
RecordDeliveryFailure(ctx context.Context, arg RecordDeliveryFailureParams) (string, error)
|
||||
// Counts one failed code or password attempt against an open code. The
|
||||
// single UPDATE reads and writes the counter under the row lock, so concurrent
|
||||
// failures serialize and none is lost. The attempt that reaches the limit
|
||||
// invalidates the token and drops its code and pending credentials, so the
|
||||
// code and the link both stop working. A token that is no longer open matches
|
||||
// no row and is left unchanged.
|
||||
RecordFailedEmailCodeAttempt(ctx context.Context, arg RecordFailedEmailCodeAttemptParams) (bool, error)
|
||||
// The compare-and-swap of the first view: it applies only to a delivered
|
||||
// invitation at the version the caller read and before its deadline, and it
|
||||
// keeps the deadline.
|
||||
|
||||
Reference in new issue
Block a user