Reputation: 3646
I'm adding a function in my controller, the only goal is to trigger the forgot password procedure through API Request.
Here is the reset_password
method-
def reset_password
@user = User.find_by_email(params[:email])
@user.send_reset_password_instructions
respond_to do |format|
format.xml { render :xml => user_api_ressource(@user, :xml)}
format.json { render :json => user_api_ressource(@user, :json)}
end
end
I'm receiving the mail with the reset password link, it opens the page where I can set a new password but when I submit the form it says that the token is invalid.
I'm using sendgrid to send email. I think it's not a token truncate problem.
I'm running the rails application on Heroku cedar with the latest version of devise.
Any idea ?
Upvotes: 5
Views: 5489
Reputation: 22188
I just faced the same issue. In my case, it was because the user
was unscoped
. It seems like it doesn't the user is not found in that case.
It is in the Devise sources in /lib/devise/models/authenticatable.rb at line 113
recoverable = find_or_initialize_with_error_by(:reset_password_token, reset_password_token)
which do not search unscoped
.
I'll fork the repo, let me know if you are interested too.
Upvotes: 1