Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error sending password reset email when not using confirmable (reopened #124) #321

Closed
fertingoff opened this issue Jul 29, 2015 · 12 comments

Comments

@fertingoff
Copy link
Contributor

Folks, after closing #124 I still have the problem.
I'm using v0.1.32.beta9 (the most recent version as far as I see).
Any ideas? Thanks!

NoMethodError - undefined method `pending_reconfirmation?' for #<User:0x007fdd3e2d2918>:
  activemodel (4.2.0) lib/active_model/attribute_methods.rb:433:in `method_missing'
   () Users/Art/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/bundler/gems/devise_token_auth-910596fa5787/app/models/devise_token_auth/concerns/user.rb:68:in `send_reset_password_instructions'
   () Users/Art/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/bundler/gems/devise_token_auth-910596fa5787/app/controllers/devise_token_auth/passwords_controller.rb:60:in `create'
@dshcheung
Copy link

I am having the same problem, despite #124 said it was solved. Below is my error message.

I am however using v0.1.31, different then @fertingoff

NoMethodError - undefined method `pending_reconfirmation?' for #<User:0x007feeff38e7d0>:
  activemodel (4.2.0) lib/active_model/attribute_methods.rb:433:in `method_missing'
  devise_token_auth (0.1.31) app/models/devise_token_auth/concerns/user.rb:70:in `send_reset_password_instructions'
  app/controllers/override_users/passwords_controller.rb:60:in `create'
  actionpack (4.2.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (4.2.0) lib/abstract_controller/base.rb:198:in `process_action'
  actionpack (4.2.0) lib/action_controller/metal/rendering.rb:10:in `process_action'

@fertingoff
Copy link
Contributor Author

@dshcheung actually I was using v0.1.31 (last stable through bundle update) but without results. Later I noted that @qx in #124 initially reported the same problem, but then he wrote, literally "'0.1.32 fixed'". So I found the last version of v0.1.32 and did my best. Eventually I still have the same unsuccessful result.

@booleanbetrayal
Copy link
Collaborator

Please try testing this against master @fertingoff

@booleanbetrayal
Copy link
Collaborator

I've just published and pushed 0.1.32 for devise_token_auth as well as 0.0.27 for ng-token-auth (if you happen to be using that as the client). Please close this issue if fixed in the latest versions.

@fertingoff
Copy link
Contributor Author

@booleanbetrayal, thank you so much for your quick response. The error is gone with v0.1.32. But I'm facing the same problem, described by @dshcheung... Would appreciate any hints.

@dshcheung
Copy link

@booleanbetrayal @fertingoff
works perfectly now. I was using an override and some minor stuff in the password controller was not up to date. Upon updating my override controller to the newest stuff, it works perfectly. Thanks @booleanbetrayal for the quick response

@booleanbetrayal
Copy link
Collaborator

Great! @fertingoff - could you ensure that any custom overrides aren't interfering, like @dshcheung was experiencing?

@fertingoff
Copy link
Contributor Author

@booleanbetrayal
I found a reason why it doesn't work for me.

passwords_controller.rb#edit form a link for email on a line 112:

redirect_to(@resource.build_auth_url(params[:redirect_url], { token: token, client_id: client_id, reset_password: true, config: params[:config] }))

The link looks like that for me in incoming email(note, that #/reset_password is at the end, not at the beginning of FRONT-END-PART)
http://MY_SITE-API.herokuapp.com://development.MY_SITE-FRONT-END-PART.divshot.io/?client_id=wVjNbqfdJUGlmjs75VyGzw&config=default&expiry=&reset_password=true&token=LLo33FKMfTj-Bf5pZKb4uw&uid=stb08201%40drisd.com#/reset_password
When I manually change the route everything works like a charm.

I found, that this twist is made by line 234 in models/devise_token_auth/concerns/user.rb#generate_url:

def generate_url(url, params = {}) 
  uri = URI(url)
  res = "#{uri.scheme}://#{uri.host}"
  res += ":#{uri.port}" if (uri.port and uri.port != 80 and uri.port != 443)
  res += "#{uri.path}" if uri.path
  res += "?#{params.to_query}"
  #line 234 res += "##{uri.fragment}" if uri.fragment
  return res
end

Would appreciate any help or ideas.

I'm using devise_token_auth v0.1.32. and ng-token-auth v0.0.27.

Thanks!

@booleanbetrayal
Copy link
Collaborator

Hi @fertingoff - I'm a bit confused by the URL you posted. It appears to be invalid (two protocol delimiters - ://). Is that intentional? Can you re-post the URL that you're receiving as well as the URL that actually works?

The fragment portion in generate_url was moved to account for the RFC that states the fragment should always follow the query string values. We've noticed some parsing issues in earlier versions of angular though, and perhaps there's something else we need to do to account for the fragments in ng-token-auth

@fertingoff
Copy link
Contributor Author

Hi @booleanbetrayal
Here is a link from reset password email:

http://mysite-api.herokuapp.com/api/v1/auth/password/edit?config=default&redirect_url=development.mysite-front-end.divshot.io%2F%23%2Freset_password&reset_password_token=qExgkpVYVWR7WVsmupts

Here is what I have in logs (pay attention to line number 4):

2015-07-31T09:54:49.393012+00:00 app[web.1]: Started GET "/api/v1/auth/password/edit?config=default&redirect_url=development.my-site-front-end.divshot.io%2F%23%2Freset_password&reset_password_token=[FILTERED]" for 213.108.75.210 at 2015-07-31 09:54:49 +0000
2015-07-31T09:54:49.618464+00:00 app[web.1]: Completed 302 Found in 222ms (ActiveRecord: 19.8ms)
2015-07-31T09:54:49.396163+00:00 app[web.1]: Processing by DeviseTokenAuth::PasswordsController#edit as HTML
2015-07-31T09:54:49.618292+00:00 app[web.1]: Redirected to http://my-site-api.herokuapp.com://development.my-site-front-end.divshot.io/?client_id=362ebU-ld4oeuEUGkfTpCg&config=default&expiry=&reset_password=true&token=DhBgBBCxC0VjOXJ7CE1uhA&uid=art.email%40gmail.com#/reset_password
2015-07-31T09:54:49.396181+00:00 app[web.1]:   Parameters: {"config"=>"default", "redirect_url"=>"development.my-site-front-end.divshot.io/#/reset_password", "reset_password_token"=>"[FILTERED]"}
2015-07-31T09:54:49.619031+00:00 app[web.1]: Oink Action: devise_token_auth/passwords#edit
2015-07-31T09:54:49.619078+00:00 app[web.1]: Memory usage: 803012 | PID: 3
2015-07-31T09:54:49.619118+00:00 app[web.1]: Oink Log Entry Complete
2015-07-31T09:54:49.619102+00:00 app[web.1]: Instantiation Breakdown: Total: 0
2015-07-31T09:54:49.625524+00:00 heroku[router]: at=info method=GET path="/api/v1/auth/password/edit?config=default&redirect_url=development.my-site-front-end.divshot.io%2F%23%2Freset_password&reset_password_token=qExgkpVYVWR7WVsmupts" host=my-site-api.herokuapp.com request_id=ab68eb94-4791-4e58-99a4-898116133054 fwd="213.108.75.210" dyno=web.1 connect=1ms service=230ms status=302 bytes=872
2015-07-31T09:54:49.732978+00:00 heroku[router]: at=info method=GET path="//development.my-site-front-end.divshot.io/?client_id=362ebU-ld4oeuEUGkfTpCg&config=default&expiry=&reset_password=true&token=DhBgBBCxC0VjOXJ7CE1uhA&uid=art.email%40gmail.com" host=my-site-api.herokuapp.com request_id=ba2c0719-bda1-43d7-8896-7a2bd5699824 fwd="213.108.75.210" dyno=web.1 connect=1ms service=7ms status=404 bytes=1809
2015-07-31T09:54:49.724657+00:00 app[web.1]: Started GET "//development.my-site-front-end.divshot.io/?client_id=362ebU-ld4oeuEUGkfTpCg&config=default&expiry=&reset_password=[FILTERED]&token=DhBgBBCxC0VjOXJ7CE1uhA&uid=art.email%40gmail.com" for 213.108.75.210 at 2015-07-31 09:54:49 +0000

Yeah, it looks weird but at least it works with correct link, crated manually:
development.my-site-front-end.divshot.io/#/reset_password?client_id=362ebU-ld4oeuEUGkfTpCg&config=default&expiry=&reset_password=true&token=DhBgBBCxC0VjOXJ7CE1uhA&uid=art.email%40gmail.com

Please note, that I changed nothing in gem codebase, so I still have no idea why I have two protocol delimiters.
Thank you once again!

@fertingoff
Copy link
Contributor Author

So, @booleanbetrayal what do you think, should I try to change a code of this version or it's worth to wait for possible update on this issue? thx!

@fertingoff
Copy link
Contributor Author

The problem was that we were trying to use custom routes for resetting password and it made some conflicts. There is no need to do that. Everything works automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants