如何使用适用于 JavaScript 的 AWS 开发工具包了解email_verified



如何使用适用于 JavaScript 的 AWS 开发工具包找出用户的email_verified值?

我在文档中没有找到任何内容,但我认为这必须以某种方式进行检查。我想在电子邮件未验证时将用户重定向到验证页面。

当用户登录时,我会收到一堆数据,但不幸的是,我没有获得有关电子邮件是否经过验证的任何信息:

export function* authenticateUser(username: string, password: string) {
    const authenticationData = {
        Username: username,
        Password: password,
    };
    const authenticationDetails = new AuthenticationDetails(authenticationData);
    console.log({authenticationDetails: authenticationDetails});
    return yield new Promise((resolve, reject) => {
        const cognitoUser = getCognitoUser(username);
        cognitoUser.authenticateUser(authenticationDetails, {
            onSuccess: (result) => {
                console.log({result: result});
                const idToken = result.getIdToken().getJwtToken(); // To get an ordinary token
                resolve({
                    idToken,
                    refreshToken: result.getRefreshToken().getToken(),
                });
            },
            onFailure: (err) => {
                reject(err);
            },
        });
    });
}
您必须在

用户通过身份验证后调用cognitoUser.getUserAttributes。响应将包括email_verified

最新更新