我正在尝试为AWS Cognito中设备管理的现有解决方案(使用Angular构建)添加MFA以进行用户身份验证。
但是,我在处理这个特定响应时遇到了困难,从用户体验角度来看,它实际上感觉很不完整,因此我希望如果其他人在这里有经验痛点的话,能提供帮助。
请参见用例23以获取示例实现,我的代码如下:
但是,我在处理这个特定响应时遇到了困难,从用户体验角度来看,它实际上感觉很不完整,因此我希望如果其他人在这里有经验痛点的话,能提供帮助。
请参见用例23以获取示例实现,我的代码如下:
authenticate(username: string, password: string): Observable<any> {
// init cognitoUser here
return new Observable((observer) => {
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: (result: any) => {},
onFailure: (err: Error) => {},
mfaRequired: (codeDeliveryDetails: any) => {
// SMS has just been sent automatically
// and it needs to be confirmed within this scope
// The example linked requests the code via `confirm()`
// which is awful UX...and since this is a service
// probably non-compliant with best practice
// However, without this `confirm` at this point in
// time, we have no confirmationCode below
cognitoUser.sendMFACode(confirmationCode, {
onSuccess: (result) => {
observer.next(result);
observer.complete();
}, onFailure: (err: Error) => {
observer.error(err);
observer.complete();
}
});
}
});
});
}
预期结果:
- 如果用户成功验证但尚未通过 MFA 添加此设备,则我们可以管理重定向到适当的确认代码表单页并手动触发
sendMFACode
函数(可能通过某种有限会话?)
问题:
- 我们没有会话,因此无法在此登录屏幕之外自动发送的MFA代码中询问用户...陷入困境?
- 在登录表单中添加另一个显示/隐藏字段不起作用,因为它会多次触发
sendMfaCode
函数,导致发送多个SMS代码。
是否有人已经成功跳出此流程?