devise icon indicating copy to clipboard operation
devise copied to clipboard

Duplication of reset_password_token

Open macpclinux opened this issue 12 years ago • 12 comments

I am using Devise on an Ubantu environment.

When requesting a reset email the system generates the reset_password_token and appends it to the request in the email fine as shown below:

href="http://our_private_system/users/password/edit?reset_password_token=WViq8_KXq4uejKzatjkd"

The request when sent back to devise presents the proper display to change the password but in the form I find that the reset_password_token has been duplicated as shown below:

input id="user_reset_password_token" name="user[reset_password_token]" value="WViq8_KXq4uejKzatjkd?reset_password_token=WViq8_KXq4uejKzatjkd"

As a result of the added "?reset_password_token=WViq8_KXq4uejKzatjkd" the originally created reset_password_token is not found in the database. I have manually removed the duplicate in the form using Firefox and the resulting post works fine.

DISTRIB_ID=Ubuntu DISTRIB_RELEASE=12.04 DISTRIB_CODENAME=precise DISTRIB_DESCRIPTION="Ubuntu 12.04.2 LTS"

*** LOCAL GEMS ***

actionmailer (4.0.4) actionpack (4.0.4) activemodel (4.0.4) activerecord (4.0.4) activerecord-deprecated_finders (1.0.3) activesupport (4.0.4) arel (4.0.2) atomic (1.1.16) bcrypt (3.1.7) builder (3.1.4) bundler (1.6.3, 1.2.3) coffee-rails (4.0.1) coffee-script (2.2.0) coffee-script-source (1.7.0) devise (3.2.4) erubis (2.7.0) execjs (2.2.1, 2.0.2) hike (1.2.3) i18n (0.6.9) jbuilder (1.5.3) journey (1.0.4) jquery-rails (3.1.1, 3.1.0) json (1.8.1) libv8 (3.16.14.3 x86_64-linux) mail (2.5.4) mime-types (1.25.1) minitest (4.7.5) multi_json (1.10.1, 1.9.2) orm_adapter (0.5.0) pg (0.17.1) polyglot (0.3.5, 0.3.4) rack (1.5.2) rack-test (0.6.2) rails (4.0.4) railties (4.0.4) rake (10.3.2, 10.1.1, 10.0.2) rdoc (4.1.1) ref (1.0.5) rubygems-bundler (1.1.0) rvm (1.11.3.5) sass (3.2.19, 3.2.17) sass-rails (4.0.3, 4.0.2) sdoc (0.4.0) sprockets (2.11.0) sprockets-rails (2.0.1) therubyracer (0.12.1) thor (0.19.1, 0.18.1) thread_safe (0.3.4, 0.3.1) tilt (1.4.1) treetop (1.4.15) turbolinks (2.2.2, 2.2.1) tzinfo (0.3.39) uglifier (2.5.1, 2.5.0) warden (1.2.3)

macpclinux avatar Jul 10 '14 18:07 macpclinux

Can you please provide a sample application that reproduces the error?

josevalim avatar Jul 10 '14 18:07 josevalim

I have compressed the project and am willing to send it to you. I need to know where to place the code.

macpclinux avatar Jul 11 '14 11:07 macpclinux

The ideal would be to have a sample application that reproduces the issue that you can push to Github. This makes it easier for us to find the issue, because the project is smaller, since we use most of our free time to debug those things out. It also avoids legal issues from us receiving third-party applications. :)

josevalim avatar Jul 11 '14 11:07 josevalim

Check you inbox.

macpclinux avatar Jul 11 '14 11:07 macpclinux

I have not figured out how to push the entire project to github.

macpclinux avatar Jul 11 '14 11:07 macpclinux

I am unable to reproduce the issue in the given application. :(

josevalim avatar Jul 11 '14 13:07 josevalim

I will try to build the app separate again and send that to you. I am sorry this did not work but I do know it has failed for me in both Production and Development environments. I will send something as soon as I can generate the issue in a more repeatable way.

macpclinux avatar Jul 11 '14 13:07 macpclinux

As well the code I sent you does not fail on my local 'macintosh'. I deleted all of the code from the ubantu server and moved to another directory, just in case. Pushing the code down from my machine, that did work, I am still getting the following in the log. Not the reset_password_token [FILTERED] has an appended = sign withe the token shown. I don't know why this is coming out. Possibly something with how I have the email configured. Any suggestions? This code was working before I change from one database to another. Apparently that change introduced something or a gem got upgraded to conflict. I can't figure this out and was hoping your team could provide something to help.

I, [2014-07-11T10:12:43.718855 #13902] INFO -- : Started GET "/users/password/edit?reset_password_token=[FILTERED]=5mzZiwa5yaTzHtsxiyth" for 76.177.215.27 at 2014-07-11 10:12:43 -0400 I, [2014-07-11T10:12:43.729212 #13902] INFO -- : Processing by Devise::PasswordsController#edit as HTML I, [2014-07-11T10:12:43.729749 #13902] INFO -- : Parameters: {"reset_password_token"=>"[FILTERED]"} I, [2014-07-11T10:12:43.844230 #13902] INFO -- : Rendered devise/shared/_links.erb (2.1ms) I, [2014-07-11T10:12:43.844912 #13902] INFO -- : Rendered devise/passwords/edit.html.erb within layouts/application (102.6ms) I, [2014-07-11T10:12:43.863143 #13902] INFO -- : Completed 200 OK in 132ms (Views: 128.3ms | ActiveRecord: 0.0ms) D, [2014-07-11T10:12:43.957010 #13902] DEBUG -- :

macpclinux avatar Jul 11 '14 14:07 macpclinux

You need to provide us an application that reproduces the error and push it to github. I cannot invest much more time into this but it seems something related to your app and not devise.

josevalim avatar Jul 11 '14 14:07 josevalim

I am closing this but if you provide a way to reproduce the issue and push it to github we can try to take a look.

josevalim avatar Jul 11 '14 14:07 josevalim

I'm having the same issue. It doesn't happen all the time but in some case it do not reset user password and show error that reset token is invalid. :-(

rqbukhari avatar Nov 12 '14 13:11 rqbukhari

The same issue cropped up for us, but only on our production box running nginx and SSL. In our case, the password reset emails went out with no protocol, thus defaulted to http. When the link is clicked, and hit our nginx server, it redirects to https and the params were duplicated and appended.

There are workarounds in the nginx config, or just a simple change to the config/environments/production.rb file. We went with the production.rb change which was just:

config.action_mailer.default_url_options = { :host => 'domainname'} to config.action_mailer.default_url_options = { :host => 'domainname', :protocol => "https"}

The issue and nginx workaround are discussed here: http://stackoverflow.com/questions/7546361/switched-to-ssl-and-devise-tokens-are-invalid

ghost avatar Jun 05 '15 19:06 ghost