#destroy needs to be implemented when used with devise
baobeimm opened this issue · 5 comments
Hi,
I'm getting this error when using mongo_session_store with devise. I tried with both mongo_mapper and mongoid and both hit the same problem. when trying to login, it hit the following stack trace.
I'm not sure why warden is calling destroy during login in. I tried to add destroy(env) with empty method to mongo_session_store's mongo_mapper and mongo_id's code, it stopped the warning but devise doesn't think a user has logged in when he is.
Anyone has any suggestions on how to fix this?
Thanks,
Wei
destroy needs to be implemented.
Application Trace | Framework Trace | Full Trace
actionpack (3.0.3) lib/action_dispatch/middleware/session/abstract_store.rb:252:in destroy' actionpack (3.0.3) lib/action_dispatch/middleware/session/abstract_store.rb:105:in
send'
actionpack (3.0.3) lib/action_dispatch/middleware/session/abstract_store.rb:105:in destroy' devise (1.1.5) lib/devise/rails/warden_compat.rb:106:in
reset_session'
devise (1.1.5) lib/devise/rails/warden_compat.rb:117
warden (1.0.2) lib/warden/hooks.rb:14:in call' warden (1.0.2) lib/warden/hooks.rb:14:in
_run_callbacks'
warden (1.0.2) lib/warden/hooks.rb:9:in each' warden (1.0.2) lib/warden/hooks.rb:9:in
_run_callbacks'
warden (1.0.2) lib/warden/manager.rb:53:in _run_callbacks' warden (1.0.2) lib/warden/proxy.rb:164:in
set_user'
warden (1.0.2) lib/warden/proxy.rb:275:in _perform_authentication' warden (1.0.2) lib/warden/proxy.rb:113:in
authenticate!'
devise (1.1.5) app/controllers/devise/sessions_controller.rb:13:in create' actionpack (3.0.3) lib/action_controller/metal/implicit_render.rb:4:in
send_action'
actionpack (3.0.3) lib/action_controller/metal/implicit_render.rb:4:in send_action' actionpack (3.0.3) lib/abstract_controller/base.rb:151:in
process_action'
actionpack (3.0.3) lib/action_controller/metal/rendering.rb:11:in process_action' actionpack (3.0.3) lib/abstract_controller/callbacks.rb:18:in
process_action'
activesupport (3.0.3) lib/active_support/callbacks.rb:440:in _run__1010667671__process_action__1623385099__callbacks' activesupport (3.0.3) lib/active_support/callbacks.rb:409:in
send'
activesupport (3.0.3) lib/active_support/callbacks.rb:409:in _run_process_action_callbacks' activesupport (3.0.3) lib/active_support/callbacks.rb:93:in
send'
activesupport (3.0.3) lib/active_support/callbacks.rb:93:in run_callbacks' actionpack (3.0.3) lib/abstract_controller/callbacks.rb:17:in
process_action'
actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:30:in process_action' activesupport (3.0.3) lib/active_support/notifications.rb:52:in
instrument'
activesupport (3.0.3) lib/active_support/notifications/instrumenter.rb:21:in instrument' activesupport (3.0.3) lib/active_support/notifications.rb:52:in
instrument'
actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:29:in process_action' actionpack (3.0.3) lib/action_controller/metal/rescue.rb:17:in
process_action'
actionpack (3.0.3) lib/abstract_controller/base.rb:120:in process' actionpack (3.0.3) lib/abstract_controller/rendering.rb:40:in
process'
actionpack (3.0.3) lib/action_controller/metal.rb:138:in dispatch' actionpack (3.0.3) lib/action_controller/metal/rack_delegation.rb:14:in
dispatch'
actionpack (3.0.3) lib/action_controller/metal.rb:178:in action' actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:62:in
call'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:62:in dispatch' actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:27:in
call'
actionpack (3.0.3) lib/action_dispatch/routing/mapper.rb:35:in call' rack-mount (0.6.13) lib/rack/mount/route_set.rb:148:in
call'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:93:in recognize' rack-mount (0.6.13) lib/rack/mount/code_generation.rb:68:in
optimized_each'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:92:in recognize' rack-mount (0.6.13) lib/rack/mount/route_set.rb:139:in
call'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:492:in call' warden (1.0.2) lib/warden/manager.rb:35:in
call'
warden (1.0.2) lib/warden/manager.rb:34:in catch' warden (1.0.2) lib/warden/manager.rb:34:in
call'
actionpack (3.0.3) lib/action_dispatch/middleware/best_standards_support.rb:17:in call' actionpack (3.0.3) lib/action_dispatch/middleware/head.rb:14:in
call'
rack (1.2.1) lib/rack/methodoverride.rb:24:in call' actionpack (3.0.3) lib/action_dispatch/middleware/params_parser.rb:21:in
call'
actionpack (3.0.3) lib/action_dispatch/middleware/flash.rb:182:in call' actionpack (3.0.3) lib/action_dispatch/middleware/session/abstract_store.rb:149:in
call'
actionpack (3.0.3) lib/action_dispatch/middleware/cookies.rb:295:in call' activerecord (3.0.3) lib/active_record/query_cache.rb:32:in
call'
activerecord (3.0.3) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in cache' activerecord (3.0.3) lib/active_record/query_cache.rb:12:in
cache'
activerecord (3.0.3) lib/active_record/query_cache.rb:31:in call' activerecord (3.0.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:353:in
call'
actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:46:in call' activesupport (3.0.3) lib/active_support/callbacks.rb:415:in
_run_call_callbacks'
actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:44:in call' rack (1.2.1) lib/rack/sendfile.rb:107:in
call'
actionpack (3.0.3) lib/action_dispatch/middleware/remote_ip.rb:48:in call' actionpack (3.0.3) lib/action_dispatch/middleware/show_exceptions.rb:46:in
call'
railties (3.0.3) lib/rails/rack/logger.rb:13:in call' rack (1.2.1) lib/rack/runtime.rb:17:in
call'
activesupport (3.0.3) lib/active_support/cache/strategy/local_cache.rb:72:in call' rack (1.2.1) lib/rack/lock.rb:11:in
call'
rack (1.2.1) lib/rack/lock.rb:11:in synchronize' rack (1.2.1) lib/rack/lock.rb:11:in
call'
actionpack (3.0.3) lib/action_dispatch/middleware/static.rb:30:in call' railties (3.0.3) lib/rails/application.rb:168:in
call'
railties (3.0.3) lib/rails/application.rb:77:in send' railties (3.0.3) lib/rails/application.rb:77:in
method_missing'
railties (3.0.3) lib/rails/rack/log_tailer.rb:14:in call' rack (1.2.1) lib/rack/content_length.rb:13:in
call'
rack (1.2.1) lib/rack/handler/webrick.rb:52:in service' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in
service'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in run' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:173:in
start_thread'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in start' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in
start_thread'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:95:in start' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in
each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in start' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:23:in
start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:82:in start' rack (1.2.1) lib/rack/handler/webrick.rb:13:in
run'
rack (1.2.1) lib/rack/server.rb:213:in start' railties (3.0.3) lib/rails/commands/server.rb:65:in
start'
railties (3.0.3) lib/rails/commands.rb:30
railties (3.0.3) lib/rails/commands.rb:27:in tap' railties (3.0.3) lib/rails/commands.rb:27 script/rails:6:in
require'
script/rails:6
I have the same problem. This didn't happen with devise 1.1.3 and warden 0.10.7
I believe this fork fixes this issue
I had to reopen the class and implement it:
ActionDispatch::Session::MongoidStore.class_eval do
def destroy(env)
session = env[ActionDispatch::Session::MongoidStore::SESSION_RECORD_KEY]
# clear the env, otherwise it get can get picked up again in set_session
env[ActionDispatch::Session::MongoidStore::SESSION_RECORD_KEY] = nil
session.destroy
end
end
I needed to clear the cached session record, otherwise for some reason rails would find it on a subsequent (separate) request. I don't know why a fresh environment is not used each time. Perhaps this only happens in test?
It looks like the brianhempel fork introduces a clause which might protect against this.
ahamid,
your solution worked nice for me =)
Anyone knows how can I clear the collection after logout?