-
Notifications
You must be signed in to change notification settings - Fork 177
req.user is undefined #457
Comments
@Arithgale My understanding is that Try this: // Called after sign in
app.post('/callback',
passport.authenticate('azuread-openidconnect',
{
failureRedirect: '/',
}
),
function(req, res) {
console.log(req.user);
console.log(req.body.user);
console.dir('Req body: ' + JSON.stringify(req.body));
console.log('\n\nReq session: ' + JSON.stringify(req.session));
res.redirect('/');
}
); |
Thanks. That was indeed what was causing the problem with the signInComplete function not being called. Although now that it is being called, |
Figured it out. To make Given that the documentation marks the If the profile argument is going to be used on the verification function, the scope must specify If it helps to anyone, once the signInComplete function is called, serializeUser is called. The signInComplete function will pass to the
|
@Arithgale Thanks, that's good feedback. In our other libraries we always provide |
Since it was just a question I closed the issue. Thanks for the help everyone. It's working now. |
Changing my |
Originally Passport indicates that if login is successful the
req.user
property will be set. The documentation for this library says the same. When I use the library however req.user is undefined. Moreover, the verify function in the documentation is never called. I have put breakpoints on it while using Visual Studio Code and also tried to use console.log, but the function is never called. Serialize and deserialize functions passed to passport are never called either.The library instead is returning the id_token and code (accessToken) in the
req.body
property. It also returns in that body the nonce and state. I know the passport session is working because it is effectively creating a session. The code below prints the session to the console. Does the documentation need to be updated to show that information is actually returned inreq.body
and contrary to Passport documentation, this library never setsreq.user
? Am I doing something wrong?As of the moment of writing this I am using the latest version of all libraries.
Express version: 4.17.1
express-session version: 1.17.0
passport-azure-ad version: 4.2.0
Here is the code I have been using for testing. The clientID is not the actual app client ID and the tenantID in the identityMetadata url is not the actual tenantID for my test app.
The text was updated successfully, but these errors were encountered: