![](/img/trans.png)
[英]How to allow my users to use either mobilen-number or email address to reset their password on Cognito User Pools?
[英]How to confirm user in Cognito User Pools without verifying email or phone?
我正在使用 適用於 JavaScript 的 Amazon Cognito 身份開發工具包(已棄用)。
我在沒有驗證電子郵件和電話號碼的情況下創建了新池。
默認情況下,不會在 Cognito 用戶池中確認用戶,因此我需要手動執行此操作。
如何在不驗證電子郵件或電話的情況下確認 Cognito 用戶池中的用戶?
我希望這會幫助別人。
為此,您可以添加此Lambda函數:
exports.handler = (event, context, callback) => {
event.response.autoConfirmUser = true;
event.response.autoVerifyEmail = true; // this is NOT needed if e-mail is not in attributeList
event.response.autoVerifyPhone = true; // this is NOT needed if phone # is not in attributeList
context.done(null, event);
};
然后導航到AWS Cognito的常規設置>>觸發器並將此Lambda函數添加到“預注冊” - 單擊下拉列表並選擇帶有上述代碼的Lambda函數。
如果您只使用'preferred_username'(如果沒有使用電子郵件或電話號碼),則將event.response.autoConfirmUser設置為true即可。
實際上,AWS最近還添加了驗證電子郵件和驗證預注冊 lambda中的電話號碼的功能 。 你基本上需要在lambda中設置autoVerifyEmail和autoVerifyPhone ,他們將得到驗證。 官方文檔中的更多信息。
"response": {
"autoConfirmUser": boolean
"autoVerifyEmail": boolean
"autoVerifyPhone": boolean
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.