Browse Source

feat: helping functions for disabling users

pull/397/head
Igli Manaj 2 years ago
parent
commit
6b30631378
  1. 22
      src/keycloak/keycloak_admin.py

22
src/keycloak/keycloak_admin.py

@ -762,6 +762,28 @@ class KeycloakAdmin:
)
return raise_error_from_response(data_raw, KeycloakPutError, expected_codes=[204])
def disable_user(self, user_id):
"""Disable the user from the realm. Disabled users can not log in.
:param user_id: User id
:type user_id: str
:return: Http response
:rtype: bytes
"""
return self.update_user(user_id=user_id, payload={"enabled": False})
def disable_all_users(self):
"""Disable all existing users.
"""
users = self.get_users()
for user in users:
user_id = user["id"]
print(f"Disabling user with id: {user_id}")
self.disable_user(user_id=user_id)
def delete_user(self, user_id):
"""Delete the user.

Loading…
Cancel
Save