angular - AWS Amplify UI - 输入确认码后“无法获取登录用户”
问题描述
当我确认注册时,我遇到了 Amplify Cognito UI 没有进入下一阶段的问题。在本地运行时会发生这种情况,我还没有尝试过。
UI 的其余部分正常工作(当您注册时,它会移动到“输入您的确认码”对话框,我可以使用现有用户正确登录),但是当我输入我的代码并单击确认时,我得到以下信息控制台中的错误,它保持在同一屏幕上。
AuthClass - Failed to get the signed in user – "No current user"
但是,查看 Cognito 控制台,用户已更改为 CONFIRMED 状态,所以我知道它正在工作。
我正在手动使用放大(即我没有使用任何 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 示例进入登录屏幕,还是应该进入登录屏幕。文档对预期的流程不是很清楚。
但我知道它不应该停留在那个屏幕上,控制台出现错误!
有谁知道我在这里做错了什么,或者我需要做什么才能将 UI 踢到流程的下一部分?
谢谢
解决方案
我也有这个问题。这是因为我在确认后注册中应用了 Lambda 触发器。
如果您使用的是确认后触发器,则该 lambda 函数必须返回未更改的事件。
推荐阅读
- notifications - X 时间延迟后批准拉取请求待处理通知
- python - 我的代码正在运行但没有输出,这是什么问题?
- excel - 循环n->x,扫描col f是否存在,写入col a。总是应用程序或对象错误
- wpf - WPF:当他的上下文 id 更改时,我应该如何更改按钮的样式?
- node.js - 在 AppEngine 上使用 @google-cloud/tasks 运行 Mocha 测试时出现问题(@grpc/grpc-js 仅适用于 Node ^8.13.0 || >=10.10.0)
- php - 我的图片无法加载到自定义 wordpress 主题中
- swiftui - 删除/更改 SwiftUI 列表中的部分标题背景颜色
- flutter - 如何在“flutter_background_fetch”中实现“flutter_local_notifications”插件以在 Flutter 中无需 FIREBASE 的情况下在线推送通知
- hyperledger-fabric - 在对等方上调用事务时出现连接错误
- jquery - 将多个 JSON 文件合并为一个 - jQuery