繁体   English   中英

AWS Amplify UI - 输入确认码后“无法获取登录用户”

[英]AWS Amplify UI - "Failed to get the signed in user" after entering confirmation code

当我确认注册时,Amplify Cognito UI 无法进入下一阶段时遇到问题。 这是在本地运行时发生的,我还没有现场尝试过。

UI 的 rest 工作正常(当您注册时,它会移动到“输入您的确认码”对话框,我可以使用现有用户正确登录),但是当我输入我的代码并单击确认时,我得到以下信息控制台中出现错误,并且它停留在同一屏幕上。

AuthClass - Failed to get the signed in user – "No current user"

在此处输入图像描述

但是,查看 Cognito 控制台,用户已更改为 CONFIRMED state,所以我知道它正在运行。

我正在手动使用放大(即我没有使用任何 CLI 元素或后端,而是将其连接到现有的 Cognito 用户池中)。

这是我的 AWS 配置(如前所述,手动滚动,屏蔽了一些 ID)

const awsConfig = {
    Auth: {
        region: 'eu-west-1',
        userPoolId: 'eu-west-1_xxxxxxx',
        userPoolWebClientId: 'xxxxxxxxxxxxxxxxxxxxxx',
        mandatorySignIn: true,

        authenticationFlowType: 'USER_PASSWORD_AUTH',

        oauth: {
            scope: ['email', 'aws.cognito.signin.user.admin'],
            redirectSignIn: 'http://localhost:3000/',
            redirectSignOut: 'http://localhost:3000/',
            responseType: 'code',
        },
    },
};

在我的组件 ts 文件中,我几乎遵循了他们的示例

export class SignInComponent implements OnInit, OnDestroy {

    user: CognitoUserInterface | undefined;
    authState: AuthState | undefined;

    signUpFormFields: FormFieldTypes;

    constructor(private _ref: ChangeDetectorRef) {
        this.signUpFormFields = [
            {
                type: 'email',
                label: 'Email Address',
                placeholder: 'you@email.com',
                required: true,
            },
            {
                type: 'given_name',
                label: 'First Name',
                placeholder: '',
                required: true,
            },
            {
                type: 'family_name',
                label: 'Last Name',
                placeholder: '',
                required: true,
            },
            {
                type: 'password',
                label: 'Password',
                placeholder: '',
                required: true,
            },
        ];

        onAuthUIStateChange((newAuthState) => {
            console.log(newAuthState);
        });
    }

    ngOnInit(): void {
        onAuthUIStateChange((authState, authData) => {
            this.authState = authState;
            this.user = authData as CognitoUserInterface;
            this._ref.detectChanges();
        });
    }

    ngOnDestroy(): (authStateHandler: AuthStateHandler) => () => void {
        return onAuthUIStateChange;
    }

}

与 HTML 元素相同

<amplify-authenticator *ngIf="authState !== 'signedin'" usernameAlias="email">
    <amplify-sign-up slot="sign-up" usernameAlias="email" [formFields]="signUpFormFields"></amplify-sign-up>
    <amplify-sign-in slot="sign-in" usernameAlias="email"></amplify-sign-in>
</amplify-authenticator>

<div *ngIf="authState === 'signedin' && user" class="App">
    <amplify-sign-out></amplify-sign-out>
    <div>Hello, {{user.username}}</div>
    <!-- This is where you application template code goes -->
</div>

我不确定这里实际应该发生什么,应该按照此处的 Cognito 示例将 go 转到登录屏幕,还是应该将 go 转到登录屏幕。 文档对预期流程不是很清楚。

但我知道它不应该停留在控制台错误的那个屏幕上!

有没有人知道我在这里做错了什么,或者我需要做什么才能将 UI 踢到流程的下一部分?

谢谢

我也有这个问题。 这是因为我将 Lambda 触发器应用于确认后注册。

如果您使用的是后确认触发器,则 lambda function 必须返回未更改的事件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM