fix: magic code 500 error on wrong code or expired code (#4521)

This commit is contained in:
Nikhil 2024-05-20 12:56:29 +05:30 committed by GitHub
parent 193076636a
commit 35f3716cb5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -88,7 +88,7 @@ class MagicCodeProvider(CredentialAdapter):
if data["current_attempt"] > 2:
email = str(self.key).replace("magic_", "", 1)
if User.objects.exists(email=email):
if User.objects.filter(email=email).exists():
raise AuthenticationException(
error_code=AUTHENTICATION_ERROR_CODES[
"EMAIL_CODE_ATTEMPT_EXHAUSTED_SIGN_IN"
@ -144,7 +144,7 @@ class MagicCodeProvider(CredentialAdapter):
return
else:
email = str(self.key).replace("magic_", "", 1)
if User.objects.exists(email=email):
if User.objects.filter(email=email).exists():
raise AuthenticationException(
error_code=AUTHENTICATION_ERROR_CODES[
"INVALID_MAGIC_CODE_SIGN_IN"
@ -162,7 +162,7 @@ class MagicCodeProvider(CredentialAdapter):
)
else:
email = str(self.key).replace("magic_", "", 1)
if User.objects.exists(email=email):
if User.objects.filter(email=email).exists():
raise AuthenticationException(
error_code=AUTHENTICATION_ERROR_CODES[
"EXPIRED_MAGIC_CODE_SIGN_IN"