Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion for authenticate handler override #6

Open
joeauty opened this issue Oct 25, 2016 · 1 comment
Open

Suggestion for authenticate handler override #6

joeauty opened this issue Oct 25, 2016 · 1 comment

Comments

@joeauty
Copy link

joeauty commented Oct 25, 2016

Hello,

It took me some time to grasp the concepts behind the authorize flow, and overriding the authenticate handler. There are numerous threads about this in the node-oauth2-server project, as I'm sure you are aware. I think even if your example included this commented out, this might be helpful?

Something like this?

oauth.authorize(request, response, {
      authenticateHandler: {
        handle: function(req, res) {
          if (req.body.userId) {
            // return full user object if necessary, otherwise just the ID
            return req.body.userId;
          }
          else {
            // redirect to login form
          }
        }
      }
    })
    .then(function(success) {
      console.log("SUCCESS", success);
      cb(false, success);
    })
    .catch(function(err) {
      console.log("AUTH ERR", err);
      cb(err);
    })
@manjeshpv
Copy link
Owner

Hi can you create a pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants