Reputation: 228
I have this problem in ActiveAdmin. When I try to reset a user's password with devise send_reset_password_instructions
.
member_action :reset_password, method: :get do
resource.send_reset_password_instructions
redirect_to users_path, notice: "instructions sent"
end
I receive the email but when I try to set the new password I get the error reset password token is invalid
. When I do the same process but within my webapp, the token is valid and the new password is set.
Any ideas/suggestions?
Upvotes: 0
Views: 38
Reputation: 228
Thanks to cursor ai, I finally made it work. I had to make a custom mailer and encrypt the 'public' token using Devise token_generator and then pass that token to the url. Like this:
encrypted_token = Devise.token_generator.digest(record, :reset_password_token, token)
record.reset_password_token = encrypted_token
record.reset_password_sent_at = Time.now.utc
record.save(validate: false)
@url = edit_password_url(record, reset_password_token: @token,
subdomain: my_subdomain)
Now it works through ActiveAdmin and the web itself. Hope it helps someone
Upvotes: 0