@@ -16,8 +16,21 @@ type Querier interface { |
| 16 | 16 | // window is older than the supplied window-start cutoff, resets to 1 and |
| 17 | 17 | // starts a new window. Returns the post-bump (hits, window_started_at). |
| 18 | 18 | BumpAuthThrottle(ctx context.Context, db DBTX, arg BumpAuthThrottleParams) (BumpAuthThrottleRow, error) |
| 19 | + // Atomically advances last_used_counter only when the proposed counter is |
| 20 | + // strictly greater. Returns rows affected — 0 means a replay attempt and |
| 21 | + // the caller should reject the code. |
| 22 | + BumpTOTPCounter(ctx context.Context, db DBTX, arg BumpTOTPCounterParams) (int64, error) |
| 23 | + // Sets confirmed_at on a pending row. Returns the number of rows updated; |
| 24 | + // callers MUST check this to handle the parallel-enrollment race |
| 25 | + // (only one of two concurrent confirms wins). |
| 26 | + ConfirmUserTOTP(ctx context.Context, db DBTX, arg ConfirmUserTOTPParams) (int64, error) |
| 19 | 27 | ConsumeEmailVerification(ctx context.Context, db DBTX, id int64) error |
| 20 | 28 | ConsumePasswordReset(ctx context.Context, db DBTX, id int64) error |
| 29 | + // Atomically marks a code as used iff it exists for the user, matches the |
| 30 | + // supplied hash, and isn't already used. Rows-affected==1 means accepted; |
| 31 | + // 0 means rejected. |
| 32 | + ConsumeRecoveryCode(ctx context.Context, db DBTX, arg ConsumeRecoveryCodeParams) (int64, error) |
| 33 | + CountUnusedRecoveryCodes(ctx context.Context, db DBTX, userID int64) (int64, error) |
| 21 | 34 | CountUsers(ctx context.Context, db DBTX) (int64, error) |
| 22 | 35 | // SPDX-License-Identifier: AGPL-3.0-or-later |
| 23 | 36 | CreateEmailVerification(ctx context.Context, db DBTX, arg CreateEmailVerificationParams) (EmailVerification, error) |
@@ -29,6 +42,8 @@ type Querier interface { |
| 29 | 42 | CreateUserEmail(ctx context.Context, db DBTX, arg CreateUserEmailParams) (UserEmail, error) |
| 30 | 43 | DeleteExpiredEmailVerifications(ctx context.Context, db DBTX) error |
| 31 | 44 | DeleteExpiredPasswordResets(ctx context.Context, db DBTX) error |
| 45 | + DeleteUserRecoveryCodes(ctx context.Context, db DBTX, userID int64) error |
| 46 | + DeleteUserTOTP(ctx context.Context, db DBTX, userID int64) error |
| 32 | 47 | GetEmailVerificationByTokenHash(ctx context.Context, db DBTX, tokenHash []byte) (EmailVerification, error) |
| 33 | 48 | GetPasswordResetByTokenHash(ctx context.Context, db DBTX, tokenHash []byte) (PasswordReset, error) |
| 34 | 49 | GetUserByID(ctx context.Context, db DBTX, id int64) (User, error) |
@@ -36,9 +51,15 @@ type Querier interface { |
| 36 | 51 | GetUserEmailByAddress(ctx context.Context, db DBTX, email string) (UserEmail, error) |
| 37 | 52 | GetUserEmailByID(ctx context.Context, db DBTX, id int64) (UserEmail, error) |
| 38 | 53 | GetUserEmailByVerificationHash(ctx context.Context, db DBTX, verificationTokenHash []byte) (UserEmail, error) |
| 54 | + GetUserTOTP(ctx context.Context, db DBTX, userID int64) (UserTotp, error) |
| 55 | + // SPDX-License-Identifier: AGPL-3.0-or-later |
| 56 | + InsertAuditLog(ctx context.Context, db DBTX, arg InsertAuditLogParams) error |
| 57 | + // SPDX-License-Identifier: AGPL-3.0-or-later |
| 58 | + InsertRecoveryCode(ctx context.Context, db DBTX, arg InsertRecoveryCodeParams) error |
| 39 | 59 | // Sets the FK only. Does NOT flip users.email_verified — that happens via |
| 40 | 60 | // MarkUserEmailPrimaryVerified after the user clicks the verification link. |
| 41 | 61 | LinkUserPrimaryEmail(ctx context.Context, db DBTX, arg LinkUserPrimaryEmailParams) error |
| 62 | + ListAuditLogForTarget(ctx context.Context, db DBTX, arg ListAuditLogForTargetParams) ([]AuthAuditLog, error) |
| 42 | 63 | ListUserEmailsForUser(ctx context.Context, db DBTX, userID int64) ([]UserEmail, error) |
| 43 | 64 | // Called after MarkUserEmailVerified for the primary email, to flip the |
| 44 | 65 | // denormalized users.email_verified flag. |
@@ -51,6 +72,11 @@ type Querier interface { |
| 51 | 72 | SuspendUser(ctx context.Context, db DBTX, arg SuspendUserParams) error |
| 52 | 73 | TouchUserLastLogin(ctx context.Context, db DBTX, id int64) error |
| 53 | 74 | UpdateUserPassword(ctx context.Context, db DBTX, arg UpdateUserPasswordParams) error |
| 75 | + // SPDX-License-Identifier: AGPL-3.0-or-later |
| 76 | + // Inserts a new pending TOTP row, or replaces an existing pending row for |
| 77 | + // the same user. Confirmed rows are NOT replaced — disable+regenerate |
| 78 | + // must go through the dedicated query. |
| 79 | + UpsertUserTOTP(ctx context.Context, db DBTX, arg UpsertUserTOTPParams) (UserTotp, error) |
| 54 | 80 | } |
| 55 | 81 | |
| 56 | 82 | var _ Querier = (*Queries)(nil) |