in django_airavata/apps/auth/views.py [0:0]
def forgot_password(request):
if request.method == 'POST':
form = forms.ForgotPasswordForm(request.POST)
if form.is_valid():
try:
username = form.cleaned_data['username']
user_exists = iam_admin_client.is_user_exist(username)
if user_exists:
user_enabled = iam_admin_client.is_user_enabled(username)
if not user_enabled:
messages.error(
request,
"Please finish creating your account before "
"resetting your password. Provide your username "
"below and we will send you another email "
"verification link.")
return redirect(
reverse('django_airavata_auth:resend_email_link'))
_create_and_send_password_reset_request_link(
request, username)
# Always display this message even if you doesn't exist. Don't
# reveal whether a user with that username exists.
messages.success(
request,
"Reset password request processed successfully. We've "
"sent an email with a password reset link to the email "
"address associated with the username you provided. You "
"can use that link within the next 24 hours to set a new "
"password.")
return redirect(
reverse('django_airavata_auth:forgot_password'))
except Exception as e:
logger.exception(
"Failed to generate password reset request for user",
exc_info=e, extra={'request': request})
form.add_error(None, ValidationError(str(e)))
else:
form = forms.ForgotPasswordForm()
return render(request, 'django_airavata_auth/forgot_password.html', {
'form': form
})