diff --git a/hosting/views.py b/hosting/views.py index 4633748a..83995ac4 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -399,23 +399,27 @@ class PasswordResetConfirmView(HostingContextMixin, ldap_manager = LdapManager() new_password = form.cleaned_data['new_password2'] + # Make sure the user have an ldap account already user.create_ldap_account(new_password) - user.set_password(new_password) - user.save() - ldap_manager.change_password(user.username, new_password) - messages.success(request, _('Password has been reset.')) + # We are changing password in ldap before changing in database because + # ldap have more chances of failure than local database + if ldap_manager.change_password(user.username, new_password): + user.set_password(new_password) + user.save() - # Change opennebula password - opennebula_client.change_user_password(user.password) + messages.success(request, _('Password has been reset.')) - return self.form_valid(form) - else: - messages.error( - request, _('Password reset has not been successful.')) - form.add_error(None, - _('Password reset has not been successful.')) - return self.form_invalid(form) + # Change opennebula password + opennebula_client.change_user_password(user.password) + + return self.form_valid(form) + + messages.error( + request, _('Password reset has not been successful.')) + form.add_error(None, + _('Password reset has not been successful.')) + return self.form_invalid(form) else: error_msg = _('The reset password link is no longer valid.') diff --git a/membership/models.py b/membership/models.py index 5ec6cb6c..3a3f65d2 100644 --- a/membership/models.py +++ b/membership/models.py @@ -74,7 +74,6 @@ def get_validation_slug(): def get_first_and_last_name(full_name): first_name, *last_name = full_name.split(" ") - first_name = first_name last_name = " ".join(last_name) return first_name, last_name