atmos / warden-github

:lock: warden strategy for github oauth
MIT License
54 stars 41 forks source link

callbacks for after_set_user authentication event is being prevented from called #47

Open ippeiukai opened 9 years ago

ippeiukai commented 9 years ago

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_authenticationWarden::Proxy#set_userWarden::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.