Updated error msg in login

This commit is contained in:
bobbyvish
2024-03-11 15:34:47 +05:30
parent d12004612a
commit 2a0bb98bd3
3 changed files with 10 additions and 5 deletions

View File

@@ -175,7 +175,7 @@ def authticate_with_otp_and_passsword(principal: IAmPrincipal, otp=None, passwor
print(password)
if not principal.check_password(password):
return ApiResponse.error(
message=constants.INVALID_PASSWORD, errors=constants.INVALID_PASSWORD
message=constants.INCORRECT_CREDENTIALS, errors=constants.INCORRECT_CREDENTIALS
)
print("after passsowrd", password)

View File

@@ -81,10 +81,14 @@ class LoginView(APIView):
password = request.data.get("password")
player_id = request.data.get("player_id")
principal = get_principal_by_email(email=email)
if isinstance(principal, Response):
return principal
try:
principal = IAmPrincipal.objects.get(email=email)
except IAmPrincipal.DoesNotExist:
error_response = {
"message": constants.INCORRECT_CREDENTIALS,
"errors": constants.INCORRECT_CREDENTIALS,
}
return ApiResponse.error(**error_response)
validation_result = authticate_with_otp_and_passsword(
principal, otp=otp, password=password

View File

@@ -34,6 +34,7 @@ SESSION_EXPIRED = "Your session has expired. Please log in again."
ACCOUNT_DEACTIVATED = "Your account is inactive. Please contact support."
EMAIL_EXISTS = "This email address is already in use. Please use a different email."
INVALID_EMAIL_PASSWORD = "Invalid email or password."
INCORRECT_CREDENTIALS = "Invalid Credentials"
INVALID_PASSWORD = "Invalid password."
PASSWORD_NOT_MATCH = "Password do not match"
INVALID_OPERATION = "Invalid operation requested."