lynndylanhurley / devise_token_auth

Token based authentication for Rails JSON APIs. Designed to work with jToker and ng-token-auth.
Do What The F*ck You Want To Public License
3.52k stars 1.14k forks source link

route not found from link in email password reset #324

Open epaillous opened 8 years ago

epaillous commented 8 years ago

I' am trying use the password reset function of devise in a mobile application. I'm calling http://{{url}}/auth/password, with email ="my email" redirect_url = "http://{{url}}/auth/password/edit" (where {url} is my server url) I receive the email, but when I try the link inside it, I'm getting "Routing Error".

In my logs I have : Completed 302 Found in 93ms (ActiveRecord: 2.9ms) so the redirection worked

and then Started GET "/auth/password/edit" for ::1 at 2015-08-03 17:45:37 +0200 Processing by DeviseTokenAuth::PasswordsController#edit as HTML Completed 404 Not Found in 3ms (ActiveRecord: 0.0ms)

ActionController::RoutingError (Not Found): devise_token_auth (0.1.31) app/controllers/devise_token_auth/passwords_controller.rb:100:in `edit'

If I subclass passwords_controller (in overrides/passwords_controller.rb), copy/paste almost all the code from the original devise passwords controller and add : mount_devise_token_auth_for 'User', at: 'auth', controllers: { passwords: 'overrides/passwords' } everything works fine. Am I doing something wrong ? I just want the link to redirect on the classic devise page to reset password

I'm using Rails 4.2.1 and Devise 3.3

booleanbetrayal commented 8 years ago

Does upgrading to 0.1.32 resolve your issue?

epaillous commented 8 years ago

If I upgrade to 0.1.32, when I try the link in the mail I just get : { success: false }

It seems that the request is working :

Started GET "/auth/password/edit?config=default&redirect_url=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fpassword%2Fedit&reset_password_token=[FILTERED]" for ::1 at 2015-08-10 15:06:11 +0200 Processing by DeviseTokenAuth::PasswordsController#edit as HTML Parameters: {"config"=>"default", "redirect_url"=>"http://localhost:3000/auth/password/edit", "reset_password_token"=>"[FILTERED]"}

And then the redirection is :

Redirected to http://localhost:3000/auth/password/edit?client_id=PDnSTmp_1UPoNrNN8fpyWA&config=default&expiry=&reset_password=true&token=2hDpQFbjNwKv4GukOAg3ZA&uid=test0c%40mail.com Completed 302 Found in 93ms (ActiveRecord: 2.9ms)

Started GET "/auth/password/edit?client_id=PDnSTmp_1UPoNrNN8fpyWA&config=default&expiry=&reset_password=[FILTERED]&token=2hDpQFbjNwKv4GukOAg3ZA&uid=test0c%40mail.com" for ::1 at 2015-08-10 15:06:11 +0200 Processing by DeviseTokenAuth::PasswordsController#edit as HTML Parameters: {"client_id"=>"PDnSTmp_1UPoNrNN8fpyWA", "config"=>"default", "expiry"=>"", "reset_password"=>"[FILTERED]", "token"=>"2hDpQFbjNwKv4GukOAg3ZA", "uid"=>"test0c@mail.com"}

I am expecting to have the default devise view to reset password. I get the same result if I give an empty redirect_url.

vipin8169 commented 8 years ago

I am not getting the redirect url in the e-mail, although I am sending it as a param in the POST request to{{url}}/api/v1/auth/password. "http://localhost/api/v1/auth/password/edit?reset_password_token=sJXUhFQSgDMvfoQ7RqRz"

godinezb commented 7 years ago

Just like @vipin8169, I'm facing the same issue my redirect_url is nor working. I opened issue #789.

hamzaaltaf commented 5 years ago

any solution to this issue?

Polidoro commented 5 years ago

I just spent a long time beating my head against this so I wanted to try to save others the headache if I can. The "Route not found" is a misleading error, it occurs even when the problem is something totally unrelated to the route.

This is the conditional that was failing for me: https://github.com/lynndylanhurley/devise_token_auth/blob/master/app/controllers/devise_token_auth/passwords_controller.rb#L41

That raises raise ActionController::RoutingError, 'Not Found' for some reason, even though the problem could be any number of non-routing issues.

I'd suggest confirming that your DeviseTokenAuth.default_password_reset_url and reset_password_token params and values match the params in the GET call.