如何查询确认已确认但email_verified为false的用户的电子邮件?
该场景大致是代理人代表他们注册用户,我通过管理员电话adminConfirmSignUp确认用户.此时,由于email_verified标志为false,用户无法更改其密码.
我无法调用resendConfirmationCode,因为用户已经确认.
我无法调用forgotPassword,因为email_verified标志为false.
我能想到的最好的方法是删除用户帐户并调用signUp(提示他们重新输入密码或新密码),从而重新创建帐户.
Lio*_*orH 22
使用AWS CLI,您可以更新email_verified属性:
aws cognito-idp admin-update-user-attributes
--user-pool-id eu-west-xxxxxx
--username xxxxyyyy@example.com
--user-attributes Name=email_verified,Value=true
Run Code Online (Sandbox Code Playgroud)
ari*_*ing 15
您可以更改email_verified,phone_number_verified并通过调用其他属性adminUpdateUserAttributes没有任何lambda表达式和触发器:
'use strict'
var AWS = require('aws-sdk')
AWS.config.update({
accessKeyId: 'YOUR_ACCESS_KEY_HERE',
secretAccessKey: 'YOUR_SECRET_ACCESS_KEY_HERE',
region: 'us-east-1' // change region if required
});
var CognitoIdentityServiceProvider = AWS.CognitoIdentityServiceProvider
var client = new CognitoIdentityServiceProvider({
apiVersion: '2016-04-19',
region: 'us-east-1' // change region if required
})
client.adminUpdateUserAttributes({
UserAttributes: [{
Name: 'phone_number_verified',
Value: 'true'
}, {
Name: 'email_verified',
Value: 'true'
}
// other user attributes like phone_number or email themselves, etc
],
UserPoolId: 'COGNITO_USER_POOL_ID_HERE',
Username: 'USERNAME'
}, function(err) {
if (err) {
console.log(err, err.stack)
} else {
console.log('Success!')
}
})
Run Code Online (Sandbox Code Playgroud)
目前,Cognito 不允许外部代理代表用户更新 email_verified 和 phone_verified 属性。将这些标记为真的唯一方法是通过可由最终用户完成的代码验证过程。例外情况是管理员级别的 API,如下面的答案所述,但不应从客户端完成。
过程是这样的:用户登录并获取访问令牌。然后,他们使用要验证的属性调用 GetUserAttrbuteVerificationCode API。这将向用户提供一个代码,可以通过调用 VerifyUserAttribute 来使用该代码,该代码将翻转属性为已验证。
现在,您可以编程设置email_verified使用预注册的λ触发与修改返回的事件为真event.response.autoVerifyEmail = true;
这不是在文档还没有,但在这个问题GitHub的引用。另请参阅使用cognito lambda触发器。
| 归档时间: |
|
| 查看次数: |
10594 次 |
| 最近记录: |