parent
1fd71fd45a
commit
1de9acb7ad
4 changed files with 81 additions and 1 deletions
|
|
@ -287,6 +287,18 @@ class CognitoIdpUser(BaseModel):
|
|||
|
||||
return user_json
|
||||
|
||||
def update_attributes(self, new_attributes):
|
||||
|
||||
def flatten_attrs(attrs):
|
||||
return {attr['Name']: attr['Value'] for attr in attrs}
|
||||
|
||||
def expand_attrs(attrs):
|
||||
return [{'Name': k, 'Value': v} for k, v in attrs.items()]
|
||||
|
||||
flat_attributes = flatten_attrs(self.attributes)
|
||||
flat_attributes.update(flatten_attrs(new_attributes))
|
||||
self.attributes = expand_attrs(flat_attributes)
|
||||
|
||||
|
||||
class CognitoIdpBackend(BaseBackend):
|
||||
|
||||
|
|
@ -673,6 +685,17 @@ class CognitoIdpBackend(BaseBackend):
|
|||
else:
|
||||
raise NotAuthorizedError(access_token)
|
||||
|
||||
def admin_update_user_attributes(self, user_pool_id, username, attributes):
|
||||
user_pool = self.user_pools.get(user_pool_id)
|
||||
if not user_pool:
|
||||
raise ResourceNotFoundError(user_pool_id)
|
||||
|
||||
if username not in user_pool.users:
|
||||
raise UserNotFoundError(username)
|
||||
|
||||
user = user_pool.users[username]
|
||||
user.update_attributes(attributes)
|
||||
|
||||
|
||||
cognitoidp_backends = {}
|
||||
for region in boto.cognito.identity.regions():
|
||||
|
|
|
|||
|
|
@ -352,6 +352,13 @@ class CognitoIdpResponse(BaseResponse):
|
|||
cognitoidp_backends[region].change_password(access_token, previous_password, proposed_password)
|
||||
return ""
|
||||
|
||||
def admin_update_user_attributes(self):
|
||||
user_pool_id = self._get_param("UserPoolId")
|
||||
username = self._get_param("Username")
|
||||
attributes = self._get_param("UserAttributes")
|
||||
cognitoidp_backends[self.region].admin_update_user_attributes(user_pool_id, username, attributes)
|
||||
return ""
|
||||
|
||||
|
||||
class CognitoIdpJsonWebKeyResponse(BaseResponse):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue