early otp expiration fix
This commit is contained in:
parent
bc68326a66
commit
7e26f15bed
|
|
@ -22,7 +22,8 @@ VALUES ($1, $2, $3, $4, $5, $6);
|
|||
SELECT id, user_id, sent_to, medium, otp_for, otp, used, used_at, created_at, expires_at
|
||||
FROM otps
|
||||
WHERE user_id = $1
|
||||
ORDER BY created_at DESC LIMIT 1;
|
||||
ORDER BY id DESC
|
||||
LIMIT 1;
|
||||
|
||||
-- name: MarkOtpAsUsed :exec
|
||||
UPDATE otps
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ const GetOtp = `-- name: GetOtp :one
|
|||
SELECT id, user_id, sent_to, medium, otp_for, otp, used, used_at, created_at, expires_at
|
||||
FROM otps
|
||||
WHERE user_id = $1
|
||||
ORDER BY created_at DESC LIMIT 1
|
||||
ORDER BY id DESC
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
type GetOtpRow struct {
|
||||
|
|
|
|||
|
|
@ -50,6 +50,10 @@ func (s *Store) GetOtp(ctx context.Context, userID int64) (domain.Otp, error) {
|
|||
}
|
||||
return domain.Otp{}, err
|
||||
}
|
||||
if !row.ExpiresAt.Valid {
|
||||
return domain.Otp{}, domain.ErrOtpNotFound
|
||||
}
|
||||
|
||||
return domain.Otp{
|
||||
ID: row.ID,
|
||||
UserID: row.UserID,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user