Fix change expired password feature

Closes-Bug: #1791111
Change-Id: I5f2a027149be490613e7661b895325a63374334d
This commit is contained in:
Ivan Kolodyazhny 2019-11-05 12:20:28 +08:00
parent b068440330
commit c0cc0433c6

View File

@ -21,6 +21,7 @@ from django import forms
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.decorators.debug import sensitive_variables from django.views.decorators.debug import sensitive_variables
from keystoneauth1 import plugin as auth_plugin
from openstack_auth import exceptions from openstack_auth import exceptions
from openstack_auth import utils from openstack_auth import utils
@ -162,7 +163,7 @@ class Login(django_auth_forms.AuthenticationForm):
return self.cleaned_data return self.cleaned_data
class DummyAuth(object): class DummyAuth(auth_plugin.BaseAuthPlugin):
"""A dummy Auth object """A dummy Auth object
It is needed for _KeystoneAdapter to get the user_id from, but otherwise It is needed for _KeystoneAdapter to get the user_id from, but otherwise
@ -174,6 +175,9 @@ class DummyAuth(object):
def __bool__(self): def __bool__(self):
return False return False
def get_headers(self, session, **kwargs):
return {}
class Password(forms.Form): class Password(forms.Form):
"""Form used for changing user's password without having to log in.""" """Form used for changing user's password without having to log in."""
@ -233,7 +237,9 @@ class Password(forms.Form):
client.users.client.endpoint_override = region client.users.client.endpoint_override = region
try: try:
client.users.update_password(original_password, password) client.users.update_password(original_password, password)
except Exception: except Exception as e:
LOG.error("Unable to update password due to exception: %s",
e)
raise forms.ValidationError( raise forms.ValidationError(
_("Unable to update the user password.")) _("Unable to update the user password."))
return self.cleaned_data return self.cleaned_data