【问题标题】:ResourceNotFoundException: user pool xyz does not exist - Cognito adminConfirmSignupResourceNotFoundException:用户池 xyz 不存在 - Cognito adminConfirmSignup
【发布时间】:2021-02-09 16:01:02
【问题描述】:

由于某种原因,只有 adminConfirmSignup 给出了用户池不存在错误。 CognitoUser 没有给出该错误。 请参考以下代码:

let cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData)
var cognitoAdmin = new AWS.CognitoIdentityServiceProvider({ region: process.env.COGNITO_POOL_REGION! });
await cognitoAdmin.adminConfirmSignUp(confirmParams, async(err, data) => { //Only this gives the user pool does not exist error
    if (err) {
        console.log(`This is the admin user confirm error ---> ${err}`)
    } else {
        console.log(`Entered else`);
        await cognitoUser.authenticateUser(authenticationDetails, {
            onSuccess: async(result) => {
                cognitoUser.changePassword(resetDetails.currentPassword, resetDetails.newPassword, (err, data) => {
                    if (err) {
                        reject(err);
                    } else {
                        console.log(`This is the success response of cognito change password -----> ${JSON.stringify(data)}`);
                        resolve(data);
                    }
                })
            },
            onFailure: (error) => {
                console.log(`This is the onFailure error ----> ${JSON.stringify(error)}`);
                reject(error);
            }
        })
    }
})

如果我使用 CognitoUser 方法(当我手动确认用户并仅使用 cognitoUser 方法进行身份验证和重置密码时),密码重置有效。

【问题讨论】:

    标签: javascript typescript amazon-cognito serverless-framework


    【解决方案1】:

    您在 SDK 调用中的参数 UserPoolId 不正确。仅凭您发布的内容将无法看到。

    【讨论】:

    • 我作为参数发送给adminConfirmSignUp 方法的confirmParams 如下所示——const confirmParams = {UserPoolId: process.env.COGNITO_USER_POOL_ID!,Username: resetDetails.emailAddress!}
    • 你有一个!
    • 嗨@Derrops,这是一个不可为空的符号。只是说环境变量不为空。我可以使用它或UserPoolId: process.env.COGNITO_USER_POOL_ID||"" 表示相同
    【解决方案2】:

    在调用该函数之前需要另一个等待

    await cognitoUser.changePassword(...)
    
    

    喜欢这个

    【讨论】:

    • 嗨@Nikola,谢谢您的回复。它说在 adminConfirmSignup 部分中找不到用户池。问题就在那里。因为异常没有进入函数。
    猜你喜欢
    • 2022-07-28
    • 1970-01-01
    • 2019-07-02
    • 1970-01-01
    • 2019-01-10
    • 1970-01-01
    • 2021-02-04
    • 1970-01-01
    • 2020-04-21
    相关资源
    最近更新 更多