weavejester/ring-oauth2

Allow supplying custom success, error handlers

kaosko opened this issue · 5 comments

Currently, redirect handler forces redirecting to the landing-uri on success but I often like to do something with the newly gained access token right away, like fetch user details, (open) id, federating with local user account etc. Would you consider supporting optional custom handlers for each profile, e.g. {:success-handler (fn [access-token] ...)}?

I assume you know that you can just put the success handler on the landing-uri, and that you're suggesting an optimisation?

Well a bit more than on optimization I guess. It's still going to do a redirect and expects a potential function to return a landing-uri. And on error, it just returns 400.

Sure, but you could do all of those things from the landing-uri. The only thing a success handler gives you, as far as I can see, is that you get to perform actions before the redirect.

Or even without a redirect. But yes, of course.

#37 partially addresses this issue, but the limitation is that :redirect-handler replaces the default handler when present. I would have thought it made more sense to always apply the default handler and then pass a success / error result to :redirect-handler when it is present. That's because we're always going to need to execute get-access-token.