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

access req.user in server.authorization() validation #201

Open
DraconPern opened this issue Mar 30, 2017 · 1 comment
Open

access req.user in server.authorization() validation #201

DraconPern opened this issue Mar 30, 2017 · 1 comment

Comments

@DraconPern
Copy link

I am trying the following..
server.authorization( function(clientID, redirectURI, done) {
// access req.user here
}
I want to check to make sure the clientID is really accessible by the user, but looking at the code, there doesn't seem to be a way. Or am I doing something really wrong?

@smaclell
Copy link

@DraconPern there is another callbacks for server.authorization you can use to respond based on the user.

The full signature for server.authorization is:

Server.prototype.authorization = function(options, validate, immediate, complete) {

By default you only need to use validate which validates only the client and not the user. For your use case you want to also use immediate. Using this other callback you can check whether the user, client and scope are valid (i.e. has the user authorized the scope for the client).

There are a number of overloads for the immediate callback, but the simplest usage would be:

function immediate(client, user, scope, done) {
  // access user and client here
  // when you are finished call done(err, allow)
  // where allow is true or false, other options left out
}

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