Commit 23b0bf18 authored by Birin Sanchez's avatar Birin Sanchez

Raise a validation error when trying to recover password for an

account that is not active.
Signed-off-by: Birin Sanchez's avatarBirin Sanchez <birin.sanchez@puri.sm>
parent 8b2f6cff
Pipeline #36684 passed with stage
in 28 seconds
......@@ -36,12 +36,16 @@ class PasswordRecoveryForm(BasePasswordRecoveryForm):
def clean_username_or_email(self):
email = self.cleaned_data['username_or_email']
username = email.split('@')[0]
user_error = forms.ValidationError(
_('That account is invalid or was not found.'), code='not_found'
)
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
raise forms.ValidationError(_('That account is invalid or was not'
' found.'),
code='not_found')
raise user_error
if not user.is_active:
raise user_error
self.cleaned_data['user'] = user
return username
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment