gpt4 book ai didi

android - 如何修改 `AWS cognito`用户池中用户未认证前的电话号码?

转载 作者:行者123 更新时间:2023-11-29 01:16:51 26 4
gpt4 key购买 nike

我使用 AWS cognito 来验证用户的电话号码。我有个问题:当用户输入他的详细信息时,我将其发送到 AWS。AWS 尝试向用户的电话号码发送代码,但如果用户输入错误的号码,AWS 将返回异常“无效的电话号码”。所以我要求用户更新号码,但是当我尝试在 AWS 中更新它时,他们返回 exceptionthe user is not authenticated”。用户刚注册还未确认,如何更新号码为正确的号码?这是我的代码:

                    // Create a CognitoUserAttributes object and add user attributes 
CognitoUserAttributes userAttributes = new CognitoUserAttributes();
// Add the user attributes. Attributes are added as key-value pairs
// Adding user's given name.
// Note that the key is "given_name" which is the OIDC claim for given name
userAttributes.addAttribute("name", userName);
userAttributes.addAttribute("family_name", userFamily);
// Adding user's phone number
userAttributes.addAttribute("phone_number", prepareValidPhoneNumberForAWS(userPhone));

SignUpHandler signupCallback = new SignUpHandler()
{
int t=0;
@Override
public void onSuccess(CognitoUser cognitoUserUser, boolean userConfirmed, CognitoUserCodeDeliveryDetails cognitoUserCodeDeliveryDetails)
{
// Sign-up was successful

// Check if this user (cognitoUser) has to be confirmed
if(!userConfirmed)
{
t=0;
// This user has to be confirmed and a confirmation code was sent to the user
// cognitoUserCodeDeliveryDetails will indicate where the confirmation code was sent
// Get the confirmation code from user
}
else
{
// The user has already been confirmed
t=1;
}
}

@Override
public void onFailure(Exception exception)
{
// Sign-up failed, check exception for the cause
exception.printStackTrace();
}

};
userPool.signUpInBackground(currentUser.getUser_id(),currentUser.getUuid(),userAttributes,null,signupCallback);

最佳答案

目前,Cognito 不支持此用例,因为客户需要登录才能更新电话号码,而未经确认的帐户无法登录。一种选择是让用户使用正确的电子邮件地址创建一个新帐户。另一种选择是最终用户联系开发人员,开发人员可以使用 AdminUpdateUserAttributes更新用户电话号码。

关于android - 如何修改 `AWS cognito`用户池中用户未认证前的电话号码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38970537/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com