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:
parent
0b9903a3df
commit
2e0e542efe
4 changed files with 43 additions and 2 deletions
|
|
@ -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"):
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue