Fix changing user's own password

The original code is monkey-patching keystoneclient object to add a
user_id attribute to it. This no longer works with more recent
versions of keystoneclient, as they wrap the client in a helper
class.

I'm not happy with this solution, it's likely to have side effects
and to break again. I'm putting it up for discussion for a better
solution.

Change-Id: Idb296d1b10fa02a0b4852e96fe8cb2bdd70380e0
Closes-bug: #1776678
This commit is contained in:
Radomir Dopieralski 2018-10-12 12:20:12 +02:00
parent 683bc7ecba
commit bdb3f9d988
1 changed files with 2 additions and 1 deletions

View File

@ -566,10 +566,11 @@ def user_verify_admin_password(request, admin_password):
@profiler.trace
def user_update_own_password(request, origpassword, password):
client = keystoneclient(request, admin=False)
client.user_id = request.user.id
if VERSIONS.active < 3:
client.user_id = request.user.id
return client.users.update_own_password(origpassword, password)
else:
client.users.client.session.auth.user_id = request.user.id
return client.users.update_password(origpassword, password)