devise_token_auth: NoMethodError (undefined method `[]' for nil:NilClass):
I have this error for a couple of day now. Any leads to solve ti ?
NoMethodError (undefined method `[]' for nil:NilClass):
devise_token_auth (0.1.32.beta10) app/models/devise_token_auth/concerns/user.rb:180:in `build_auth_header'
devise_token_auth (0.1.32.beta10) app/controllers/devise_token_auth/concerns/set_user_by_token.rb:68:in `update_auth_header'
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 19 (1 by maintainers)
Commits related to this issue
- create token when no client_id token fix #286. Case of no change headers on each request. — committed to StratusPrint/devise_token_auth by charlesdg 8 years ago
Seeing this error when doing a password reset password change. I believe it might be all old tokens being wiped out with the PW update, but no new token existing yet, but haven’t been able to dig into internals enough to confirm.
This seems to be caused by a threadsafety issue in how tokens are being set for a resource (user). If two requests come in simultaneously (e.g. a client sends duplicate sessions create requests) on a multi-threaded server the second token update will overwrite the first, so when
build_auth_headerruns and looks for the token with the firstclient_idit will return nil and throw this error.