我正在尝试制作一个用于重置密码的 api,当用户按下forgot password
并向他发送带有令牌的电子邮件时,我设计了处理该部分,但我尝试在另一部分更改它我需要使用当他重置密码但设计用户(在数据库中)的reset_password_token
与电子邮件中发送的令牌不同时该令牌,我只收到token, password, password_confirmation
以使该 API 工作,所以我需要找到该用户使用电子邮件中发送的token
(User.where(reset_password_token:TOKEN)),有没有办法将电子邮件中的令牌转换为我在数据库中的令牌。
You have to check the reset_password_by_token
class method which contains the logic. But you can use it directly:
User.reset_password_by_token({
reset_password_token: token,
password: password,
password_confirmation: password_confirmation
})
Link to current master code here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.