dev: admin user deactivated

This commit is contained in:
pablohashescobar 2024-05-14 15:46:45 +05:30
parent 9e70073d96
commit 2c35461c45
2 changed files with 15 additions and 0 deletions

View File

@ -50,6 +50,7 @@ AUTHENTICATION_ERROR_CODES = {
"ADMIN_AUTHENTICATION_FAILED": 5175,
"ADMIN_USER_ALREADY_EXIST": 5180,
"ADMIN_USER_DOES_NOT_EXIST": 5185,
"ADMIN_USER_DEACTIVATED": 5190,
}

View File

@ -316,6 +316,20 @@ class InstanceAdminSignInEndpoint(View):
# Fetch the user
user = User.objects.filter(email=email).first()
# is_active
if not user.is_active:
exc = AuthenticationException(
error_code=AUTHENTICATION_ERROR_CODES[
"ADMIN_USER_DEACTIVATED"
],
error_message="ADMIN_USER_DEACTIVATED",
)
url = urljoin(
base_host(request=request, is_admin=True),
"?" + urlencode(exc.get_error_dict()),
)
return HttpResponseRedirect(url)
# Error out if the user is not present
if not user:
exc = AuthenticationException(