AWS Cognito 验证码长度更改 [英] AWS Cognito Verification Code length change

查看:20
本文介绍了AWS Cognito 验证码长度更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AWS Cognito 正在发送 6 位验证码以进行移动/电子邮件验证.

AWS Cognito is sending 6 digits verification code for mobile/email verification.

有没有办法自定义验证码的大小?
例如:将其更改为4位数

Is there any way to customize the size of the verification code?
Ex: changing it to 4 digits

我浏览了 AWS 文档,但找不到任何解决方案.

I went through the AWS documentation but couldn't find any solution.

提前致谢

推荐答案

不,你不能改变 Cognito 的内部逻辑.

No, you cannot change the internal logic of cognito.

但是,您可以创建自己的逻辑来验证用户.您可以创建一个预注册 lambda 将随机 4 位代码发送到新创建的用户的电子邮件(您可以将临时代码存储在对用户隐藏的自定义用户属性中,或者存储在带有 userid 的 dynamodb 表中,以便稍后进行比较).然后创建另一个具有 AdminUpdateUserAttributes 角色中的特权.这个 lambda 将由 apigateway 触发,它将采用 4 位代码作为输入.然后将此代码与您之前存储的代码进行比较.如果匹配,则调用 AdminUpdateUserAttributes 并将用户标记为已验证.

However, you can create your own logic to verify users. You can create a pre signup lambda to send random 4 digit code to email of the newly created user (you can store the temporary code in custom user attribute which is hidden from user or in dynamodb table with userid for comparison later). Then create another lambda which has AdminUpdateUserAttributes privileges in the role. This lambda will get triggered by apigateway which will take the 4 digit code as input. Then compare this code to the one you stored earlier. If it matches, make the AdminUpdateUserAttributes call and mark the user verified.

这篇关于AWS Cognito 验证码长度更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆