I wanted to add a logic to my app that gets triggered by authentication to certain scope.
I added a callback via Warden::Manager.after_set_user, but after_set_user callbacks never get triggered with :authentication event; I'm only seeing :fetch events.
It turned out that the first callback for after_set_user is this one (lib/warden/github/hook.rb) and it throws(:warden) in finalize_flow! which prematurely exits the entire stack of Warden::Proxy#authenticate! ⇒ Warden::Proxy#_perform_authentication ⇒ Warden::Proxy#set_user ⇒ Warden::Manager#_run_callbacks, most importantly skipping the rest of after_set_user callbacks in _run_callbacks.
Not sure if this is a bug or by design, but it would be nice to fix it or document/provide an alternative such that a process can be performed upon authentication (at the beginning of the session).
Right now, I'm using Warden::Manager.prepend_after_authentication to force my callback to come before the one above. It's not a very clean solution but probably an acceptable one if documented.
I wanted to add a logic to my app that gets triggered by authentication to certain scope. I added a callback via
Warden::Manager.after_set_user
, butafter_set_user
callbacks never get triggered with:authentication
event; I'm only seeing:fetch
events.It turned out that the first callback for
after_set_user
is this one (lib/warden/github/hook.rb) and itthrows(:warden)
infinalize_flow!
which prematurely exits the entire stack ofWarden::Proxy#authenticate!
⇒Warden::Proxy#_perform_authentication
⇒Warden::Proxy#set_user
⇒Warden::Manager#_run_callbacks
, most importantly skipping the rest ofafter_set_user
callbacks in_run_callbacks
.Not sure if this is a bug or by design, but it would be nice to fix it or document/provide an alternative such that a process can be performed upon authentication (at the beginning of the session).
Right now, I'm using
Warden::Manager.prepend_after_authentication
to force my callback to come before the one above. It's not a very clean solution but probably an acceptable one if documented.