Skip to content
This repository was archived by the owner on Jul 12, 2023. It is now read-only.

Commit efc538b

Browse files
committed
More
1 parent 78eb58e commit efc538b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pkg/database/token.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,23 @@ func (db *Database) VerifyCodeAndIssueToken(realmID uint, verCode string, accept
175175
return err
176176
}
177177

178-
if _, ok := acceptTypes[vc.TestType]; !ok {
179-
return ErrUnsupportedTestType
180-
}
181-
182178
// Validation
183-
if vc.IsExpired() {
179+
expired, err := db.IsCodeExpired(&vc, verCode)
180+
if err != nil {
181+
db.logger.Errorw("failed to check code expiration", "error", err)
182+
return ErrVerificationCodeExpired
183+
}
184+
if expired {
184185
return ErrVerificationCodeExpired
185186
}
186187
if vc.Claimed {
187188
return ErrVerificationCodeUsed
188189
}
189190

191+
if _, ok := acceptTypes[vc.TestType]; !ok {
192+
return ErrUnsupportedTestType
193+
}
194+
190195
// Mark as claimed
191196
vc.Claimed = true
192197
if err := tx.Save(&vc).Error; err != nil {

0 commit comments

Comments
 (0)