Closed DarkLite1 closed 4 years ago
@DarkLite1 sorry this went unattended. So the req.user
attribute is usually populated with session information about an authenticated user, but sessions are not common/appropriate for web API's, as API servers typically require credentials (i.e. token) to be supplied with each request. As such, our sample is not covering this.
If you have some custom logic for populating req.user
after an authorized call, you could do so at line 18 in index.js
:
const bearerStrategy = new BearerStrategy(config,
function (token, done) {
// Send user info using the second argument
done(null, { /* USER INFO */ }, token);
}
);
But for sessions you should take a look at a web app sample. You can see some such samples here.
Let me know if you need anything further.
Closing this due to inactivity. Let us know if that doesn't solve your issue.
I'm having a similar issue as this one. Following the example I have this code in
index.ts
:Which results in these console logs:
Notice that he
req.user
is undefined. According to the documentation I would expectpassport
to set this for us? Or am I missing something here? To store the user in the database we should probably use the fieldoid
as unique identifier?A similar question on StackOverlflow.
Thank you for your help.