[英]Writing Password reset using sails.js
I am stuck with user reset password. 我卡住了用户重置密码。 These are the steps that I have accomplished. 这些是我已经完成的步骤。
User selects 'reset password link'. 用户选择“重置密码链接”。
Sails.js generates GUID and saves it to a resetPassTable. Sails.js生成GUID并将其保存到resetPassTable。
Email is sent to the users email. 电子邮件发送到用户的电子邮件。
I have changePwdController that has reset action 我有具有重置操作的changePwdController
Basically I have access to that hash that is in id, something like: 基本上,我可以访问id中的哈希,例如:
var secretHash = req.param('id') var secretHash = req.param('id')
I check that hash against the one in the database, and can make decision as what to do. 我对照数据库中的哈希值检查该哈希值,并可以决定要做什么。
You should show the password reset form when the user clicks on the link from the email (this would be just rendering a view normally). 当用户单击电子邮件中的链接时,您应该显示密码重置表单(这只会正常显示视图)。 You do need to carry the hash to that view though, maybe an URL param? 但是,您确实需要将哈希值携带到该视图中,也许是URL参数?
Then once the user submits the password reset form then do the password reset or rejection if hash does not match one in the database. 然后,一旦用户提交了密码重置表单,然后在哈希与数据库中的哈希不匹配时执行密码重置或拒绝。 So you need two different actions. 因此,您需要两种不同的操作。 One for showing the view, and another one the form hits upon submission. 一种用于显示视图,另一种用于在提交时单击表格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.