add reset password
This commit is contained in:
@@ -36,3 +36,40 @@ def admin_get_user(
|
||||
return None
|
||||
else:
|
||||
return user
|
||||
|
||||
|
||||
def admin_set_user_password(
|
||||
username: str,
|
||||
password: str,
|
||||
*,
|
||||
user_pool_id: str,
|
||||
permanent: bool = False,
|
||||
idp_client,
|
||||
) -> bool:
|
||||
"""Sets the specified user's password in a user pool as an administrator.
|
||||
Works on any user.
|
||||
|
||||
The password can be temporary or permanent. If it is temporary, the user
|
||||
status enters the FORCE_CHANGE_PASSWORD state.
|
||||
|
||||
When the user next tries to sign in, the InitiateAuth/AdminInitiateAuth
|
||||
response will contain the NEW_PASSWORD_REQUIRED challenge.
|
||||
|
||||
If the user doesn't sign in before it expires, the user won't be able
|
||||
to sign in, and an administrator must reset their password.
|
||||
|
||||
Once the user has set a new password, or the password is permanent,
|
||||
the user status is set to Confirmed.
|
||||
"""
|
||||
try:
|
||||
idp_client.admin_set_user_password(
|
||||
UserPoolId=user_pool_id,
|
||||
Username=username,
|
||||
Password=password,
|
||||
Permanent=permanent,
|
||||
)
|
||||
except idp_client.exceptions as err:
|
||||
logger.exception(err)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user