mirror of
https://github.com/stardrophere/InsightRadar.git
synced 2026-06-06 01:57:51 +08:00
修改只有一次验证机会的bug
This commit is contained in:
@@ -62,15 +62,16 @@ class EmailVerificationService:
|
||||
|
||||
def verify_code(self,email: str, code: str, purpose: VerificationPurpose):
|
||||
email = email.lower()
|
||||
code_hash = hash_verification_code(code)
|
||||
|
||||
stored_hash: Optional[str] = self.repo.consume_code(email, purpose)
|
||||
stored = self.repo.compare_and_consume(email, purpose, code_hash)
|
||||
|
||||
if not stored_hash:
|
||||
raise CodeExpiredError("Code expired or not found")
|
||||
|
||||
if stored_hash != hash_verification_code(code):
|
||||
if stored == False:
|
||||
raise CodeInvalidError("Invalid code")
|
||||
|
||||
if not stored:
|
||||
raise CodeExpiredError("Code expired or not found")
|
||||
|
||||
return True
|
||||
|
||||
@lru_cache
|
||||
|
||||
Reference in New Issue
Block a user