def get_user(self, admin_token, user_id): self.__validate_admin_token(admin_token) duser = api.USER.get(user_id) if not duser: raise fault.ItemNotFoundFault("The user could not be found") return User_Update(id=duser.id, tenant_id=duser.tenant_id, email=duser.email, enabled=duser.enabled, name=duser.name)
def enable_disable_user(self, admin_token, user_id, user): self.__validate_admin_token(admin_token) duser = api.USER.get(user_id) if not duser: raise fault.ItemNotFoundFault("The user could not be found") if not isinstance(user, User): raise fault.BadRequestFault("Expecting a User") values = {'enabled': user.enabled} api.USER.update(user_id, values) duser = api.USER.get(user_id) return User_Update(enabled=user.enabled)
def set_user_tenant(self, admin_token, user_id, user): self.__validate_admin_token(admin_token) duser = api.USER.get(user_id) if not duser: raise fault.ItemNotFoundFault("The user could not be found") if not isinstance(user, User): raise fault.BadRequestFault("Expecting a User") duser = api.USER.get(user_id) if duser == None: raise fault.ItemNotFoundFault("The user could not be found") self.validate_and_fetch_user_tenant(user.tenant_id) values = {'tenant_id': user.tenant_id} api.USER.update(user_id, values) return User_Update(tenant_id=user.tenant_id)
def set_user_password(self, admin_token, user_id, user): self.__validate_admin_token(admin_token) duser = api.USER.get(user_id) if not duser: raise fault.ItemNotFoundFault("The user could not be found") if not isinstance(user, User): raise fault.BadRequestFault("Expecting a User") if not user.password: raise fault.BadRequestFault("Expecting a Password") values = {'password': user.password} api.USER.update(user_id, values) return User_Update(password=user.password)
def set_user_eppn(self, admin_token, user_id, user): self.__validate_admin_token(admin_token) duser = api.USER.get(user_id) if not duser: raise fault.ItemNotFoundFault("The user could not be found") if not isinstance(user, User): raise fault.BadRequestFault("Expecting a User") if not user.eppn: raise fault.BadRequestFault("Expecting a Eppn") if user.eppn != duser.eppn and \ api.USER.get_by_eppn(user.eppn) is not None: raise fault.EppnConflictFault("Eppn already exists") values = {'eppn': user.eppn} api.USER.update(user_id, values) return User_Update(eppn=user.eppn)
def set_user_password(self, admin_token, user_id, user): self.__validate_admin_token(admin_token) duser = api.USER.get(user_id) if not duser: raise fault.ItemNotFoundFault("The user could not be found") if not isinstance(user, User): raise fault.BadRequestFault("Expecting a User") if not user.password: raise fault.BadRequestFault("Expecting a Password") values = {'password': user.password} api.USER.update(user_id, values) dtenant = api.TENANT.get_user_tenants(user_id) secret = {'secret': user.password} api.CREDENTIALS.update_secret(dtenant[0].name + ":" + duser.name, secret) return User_Update(password=user.password)