如何重置已过期的 Cognito 用户密码?

How do I reset a Cognito user's password that has expired?

我们正在使用 Cognito。一切都很好。我使用 AdminCreateUser API 添加了一个用户,他们收到了临时密码。不幸的是,他们等了一个多月才登录,现在当他们尝试使用临时密码登录时,Cognito returns 这个错误:

User account has expired, it must be reset by an administrator.

我该怎么做?我在 Cognito UI 中没有看到任何重置按钮。有我可以调用的 CLI 或 API 吗?

命令 admin-reset-user-passwordadmin-enable-user 对已过期的用户无效。

重置过期用户的方法是使用参数 MessageAction value = 'RESEND'

再次调用 admin-create-user

例如通过 CLI 命令:

aws cognito-idp admin-create-user --region us-east-1 --user-pool-id us-east-1_youruserpoolid --username theusername --message-action RESEND

来自the documentation

"Set to 'RESEND' to resend the invitation message to a user that already exists and reset the expiration limit on the user's account."

重置用户后,用户将需要更改临时密码,否则一旦超过有效期(默认为 7 天,根据 AWS documentation).