lynndylanhurley / lynndylanhurley/devise_token_auth
Unable to destroy current user
Open
@MaicolBen is already working on this.
Since Sep 26, 2018.
- Dominant language
- Ruby
- Stars
- 3.6k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Can anyone tell me why does devise_token_auth is reloading the current user, while I've just deleted it? Obvisouly it ends in an #<ActiveRecord::RecordNotFound: Couldn't find User with 'id'=772> exception, but I can't get how to overpass this error. Is this a bug in devise_token_auth?
The error is raised by devise_token_auth-1.0.0.rc2/app/controllers/devise_token_auth/concerns/set_user_by_token.rb:L119 at @resource.reload
Here's the code snippet of my API::UsersController:
def destroy
@user = User.find(params[:id])
authorize @user
sign_out @user # I've tried to add this logout before destroying but it changes nothing
@user.destroy
head :no_content
end
- Version: 1.0.0.rc2 (I've just upgraded but the error also append previously with 0.1.37). ng-token-auth: 0.0.28. ruby: 2.2.1. rails: 4.2.0. devise: 4.5.0
- Request and response headers:
curl 'http://localhost:3000/api/users/772' -X DELETE -H 'Origin: http://localhost:3000' -H 'access-token: H88eN0OcbsyVGYnwWmTUEg' -H 'client: BeS_3rSpB4sOld3l0wTong' -H 'Accept: application/json, text/plain, */*' -H 'expiry: 1539180964' -H 'uid: txxxxxxx.xxxxxe@gmail.com' -H 'Referer: http://localhost:3000/app/account/settings' -H 'If-Modified-Since: Mon, 26 Jul 1997 05:00:00 GMT' -H 'token-type: Bearer' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/69.0.3497.81 Chrome/69.0.3497.81 Safari/537.36' --compressed
- Complete Stacktrace:
["/rvm.gems.path/activerecord-4.2.0/lib/active_record/core.rb:154:in `find'",
"/rvm.gems.path/activerecord-4.2.0/lib/active_record/persistence.rb:413:in `block in reload'",
"/rvm.gems.path/activerecord-4.2.0/lib/active_record/scoping/default.rb:33:in `block in unscoped'",
"/rvm.gems.path/activerecord-4.2.0/lib/active_record/relation.rb:302:in `scoping'",
"/rvm.gems.path/activerecord-4.2.0/lib/active_record/scoping/default.rb:33:in `unscoped'",
"/rvm.gems.path/activerecord-4.2.0/lib/active_record/persistence.rb:413:in `reload'",
"/rvm.gems.path/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:36:in `reload'",
"/rvm.gems.path/activerecord-4.2.0/lib/active_record/autosave_association.rb:219:in `reload'",
"/rvm.gems.path/devise_token_auth-1.0.0.rc2/app/controllers/devise_token_auth/concerns/set_user_by_token.rb:119:in `update_auth_header'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/callbacks.rb:427:in `block in make_lambda'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/callbacks.rb:236:in `call'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/callbacks.rb:236:in `block in halting'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/callbacks.rb:169:in `call'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/callbacks.rb:169:in `block in halting'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/callbacks.rb:151:in `call'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/callbacks.rb:92:in `call'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/callbacks.rb:92:in `_run_callbacks'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/callbacks.rb:734:in `_run_process_action_callbacks'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/callbacks.rb:81:in `run_callbacks'",
"/rvm.gems.path/actionpack-4.2.0/lib/abstract_controller/callbacks.rb:19:in `process_action'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_controller/metal/rescue.rb:29:in `process_action'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/notifications.rb:164:in `block in instrument'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/notifications.rb:164:in `instrument'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_controller/metal/instrumentation.rb:30:in `process_action'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'",
"/rvm.gems.path/activerecord-4.2.0/lib/active_record/railties/controller_runtime.rb:18:in `process_action'",
"/rvm.gems.path/actionpack-4.2.0/lib/abstract_controller/base.rb:137:in `process'",
"/rvm.gems.path/actionview-4.2.0/lib/action_view/rendering.rb:30:in `process'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_controller/metal.rb:195:in `dispatch'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_controller/metal.rb:236:in `block in action'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:73:in `call'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:42:in `serve'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_dispatch/journey/router.rb:43:in `block in serve'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_dispatch/journey/router.rb:30:in `each'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_dispatch/journey/router.rb:30:in `serve'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:802:in `call'",
"/rvm.gems.path/omniauth-1.3.1/lib/omniauth/strategy.rb:186:in `call!'",
"/rvm.gems.path/omniauth-1.3.1/lib/omniauth/strategy.rb:164:in `call'",
"/rvm.gems.path/warden-1.2.7/lib/warden/manager.rb:36:in `block in call'",
"/rvm.gems.path/warden-1.2.7/lib/warden/manager.rb:35:in `catch'",
"/rvm.gems.path/warden-1.2.7/lib/warden/manager.rb:35:in `call'",
"/rvm.gems.path/rack-1.6.4/lib/rack/etag.rb:24:in `call'",
"/rvm.gems.path/rack-1.6.4/lib/rack/conditionalget.rb:38:in `call'",
"/rvm.gems.path/rack-1.6.4/lib/rack/head.rb:13:in `call'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_dispatch/middleware/params_parser.rb:27:in `call'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_dispatch/middleware/flash.rb:260:in `call'",
"/rvm.gems.path/rack-1.6.4/lib/rack/session/abstract/id.rb:225:in `context'",
"/rvm.gems.path/rack-1.6.4/lib/rack/session/abstract/id.rb:220:in `call'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_dispatch/middleware/cookies.rb:560:in `call'",
"/rvm.gems.path/activerecord-4.2.0/lib/active_record/query_cache.rb:36:in `call'",
"/rvm.gems.path/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'",
"/rvm.gems.path/activerecord-4.2.0/lib/active_record/migration.rb:378:in `call'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/callbacks.rb:88:in `call'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/callbacks.rb:88:in `_run_callbacks'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/callbacks.rb:734:in `_run_call_callbacks'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/callbacks.rb:81:in `run_callbacks'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_dispatch/middleware/callbacks.rb:27:in `call'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_dispatch/middleware/reloader.rb:73:in `call'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_dispatch/middleware/remote_ip.rb:78:in `call'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'",
"/rvm.gems.path/web-console-2.2.1/lib/web_console/middleware.rb:39:in `call'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'",
"/rvm.gems.path/railties-4.2.0/lib/rails/rack/logger.rb:38:in `call_app'",
"/rvm.gems.path/railties-4.2.0/lib/rails/rack/logger.rb:20:in `block in call'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/tagged_logging.rb:68:in `block in tagged'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/tagged_logging.rb:26:in `tagged'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/tagged_logging.rb:68:in `tagged'",
"/rvm.gems.path/railties-4.2.0/lib/rails/rack/logger.rb:20:in `call'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_dispatch/middleware/request_id.rb:21:in `call'",
"/rvm.gems.path/rack-1.6.4/lib/rack/methodoverride.rb:22:in `call'",
"/rvm.gems.path/rack-1.6.4/lib/rack/runtime.rb:18:in `call'",
"/rvm.gems.path/activesupport-4.2.0/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'",
"/rvm.gems.path/rack-1.6.4/lib/rack/lock.rb:17:in `call'",
"/rvm.gems.path/actionpack-4.2.0/lib/action_dispatch/middleware/static.rb:113:in `call'",
"/rvm.gems.path/rack-1.6.4/lib/rack/sendfile.rb:113:in `call'",
"/rvm.gems.path/railties-4.2.0/lib/rails/engine.rb:518:in `call'",
"/rvm.gems.path/railties-4.2.0/lib/rails/application.rb:164:in `call'",
"/rvm.gems.path/rack-1.6.4/lib/rack/content_length.rb:15:in `call'",
"/rvm.gems.path/puma-2.15.3/lib/puma/server.rb:541:in `handle_request'",
"/rvm.gems.path/puma-2.15.3/lib/puma/server.rb:388:in `process_client'",
"/rvm.gems.path/puma-2.15.3/lib/puma/server.rb:270:in `block in run'",
"/rvm.gems.path/puma-2.15.3/lib/puma/thread_pool.rb:106:in `call'",
"/rvm.gems.path/puma-2.15.3/lib/puma/thread_pool.rb:106:in `block in spawn_thread'"]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.