added cognito idp function admin_set_user_password to the code (#3328)

* added cognito idp function  to the code

* fixed linting issues
This commit is contained in:
ayushbhawsar 2020-09-21 23:10:07 +05:30 committed by GitHub
commit 2e0e542efe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 2 deletions

View file

@ -353,7 +353,6 @@ class CognitoIdpUser(BaseModel):
class CognitoResourceServer(BaseModel):
def __init__(self, user_pool_id, identifier, name, scopes):
self.user_pool_id = user_pool_id
self.identifier = identifier
self.name = name
@ -1035,6 +1034,14 @@ class CognitoIdpBackend(BaseBackend):
else:
raise NotAuthorizedError(access_token)
def admin_set_user_password(self, user_pool_id, username, password, permanent):
user = self.admin_get_user(user_pool_id, username)
user.password = password
if permanent:
user.status = UserStatus["CONFIRMED"]
else:
user.status = UserStatus["FORCE_CHANGE_PASSWORD"]
cognitoidp_backends = {}
for region in Session().get_available_regions("cognito-idp"):

View file

@ -449,6 +449,16 @@ class CognitoIdpResponse(BaseResponse):
)
return ""
def admin_set_user_password(self):
user_pool_id = self._get_param("UserPoolId")
username = self._get_param("Username")
password = self._get_param("Password")
permanent = self._get_param("Permanent")
cognitoidp_backends[self.region].admin_set_user_password(
user_pool_id, username, password, permanent
)
return ""
class CognitoIdpJsonWebKeyResponse(BaseResponse):
def __init__(self):