0

I'm trying to make an api for resetting password, I made devise handle the part when the user press on forgot password and sending him an email with a token but I tried to change it in the other part I needed to look up user using that token when he reset his password but Devise reset_password_token of the user (in the DB) is not like the token sent in the email, I only receive token, password, password_confirmation to make that API work, So I need to find that user using token sent in the email(User.where(reset_password_token: TOKEN)), Is there a way to convert token in the email to the one I have in the DB.

4

1 回答 1

3

您必须检查reset_password_by_token包含逻辑的类方法。但是你可以直接使用它:

User.reset_password_by_token({
  reset_password_token: token,
  password: password,
  password_confirmation: password_confirmation
})

在此处链接到当前主代码

于 2018-02-20T12:56:50.913 回答