[英]How do I set up a user's phone number as a password recovery option in Nodejs
I'm working on a nodejs project, I used passportjs in nodejs to create a login system. 我正在开发一个nodejs项目,我在nodejs中使用了passportjs创建了一个登录系统。 Everything seems ok, but I do not know how I can go about password recovery so that in the case of a lost or forgotten password, you have the option to receive a text message (SMS) or voice call to recover your account. 一切似乎都还可以,但是我不知道如何恢复密码,因此,如果丢失或忘记了密码,您可以选择接收短信(SMS)或语音电话来恢复您的帐户。
I want trying How To Implement Password Reset In Node.js , but the example there show password recovery via email. 我想尝试如何在Node.js中实现密码重置 ,但是那里的示例显示了通过电子邮件恢复密码。
I have checked this Stackoverflow questions already, but none of them helps in what I plan to archive: 我已经检查了这个Stackoverflow问题,但是它们都对我计划存档的内容没有帮助:
I will greatly appreciate any help. 我将不胜感激任何帮助。
Thank a million in advance. 预先感谢一百万。
Disclaimer, I do not have experience in Nodejs and this is a rough example. 免责声明,我没有Nodejs经验,这是一个粗糙的示例。
Find a service that can send texts to users such as twilio. 查找可以将文本发送给用户的服务,例如twilio。 Generate an authentication code using a random generator when user presses button. 用户按下按钮时,使用随机生成器生成身份验证代码。 Use that authentication code as a key to a map where the value is the user. 使用该身份验证代码作为值为用户的映射的密钥。
Then when the user inputs the code you can lookup the User to reset using the map created before. 然后,当用户输入代码时,您可以使用之前创建的地图查找要重置的用户。
The map you would want to store in your database. 您要存储在数据库中的地图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.