Browse Source

Merged in marquardts/python-keycloak/issue/11_get-user-id-status-code-error (pull request #18)

[11] Fixed function get_user_id to return the correct value

Approved-by: Marcos Pereira <marcospereira.mpj@gmail.com>
pull/12/head
Sebastian Marquardt 6 years ago
committed by Marcos Pereira
parent
commit
e6646f1a12
  1. 11
      keycloak/keycloak_admin.py

11
keycloak/keycloak_admin.py

@ -182,15 +182,8 @@ class KeycloakAdmin:
:return: user_id
"""
data_raw = self.get_users(query={"username": username})
data_content = raise_error_from_response(data_raw, KeycloakGetError)
for user in data_content:
this_use_rname = json.dumps(user["username"]).strip('"')
if this_use_rname == username:
return json.dumps(user["id"]).strip('"')
return None
users = self.get_users(query={"username": username})
return next((user["id"] for user in users if user["username"] == username), None)
def get_user(self, user_id):
"""

Loading…
Cancel
Save