Rails devise reset_password_token continues to mark as "expired"

I am trying to use devise reset_password_token to force users to change their password at first login using what I read here: Rails Devise: Set password reset token and redirect user

I get to loading a page that says “set your password”, but every time I click submit, a notification appears saying that reset_password_token has expired and request a new one. I tried setting reset_password_token for the variable instead of accessing through the user object (@ user.reset_password_token), in case the expiration is calculated, if this token was reached, but it still says that it expired when I try to set my initial password. I'm not sure how the calculation is calculated, does anyone have an idea?

+8
devise ruby-on-rails-plugins
source share
1 answer

Found an answer!

When reset_password_token is generated, should @user.reset_password_sent_at be set to Time.now, as well as when running @user.reset_password_period_valid? to find out if the reset token is still valid, it will be zero and suppose the token has expired.

+15
source share

All Articles