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

Unable to access req.user server side #6

Open
megmatty opened this issue Nov 18, 2017 · 1 comment
Open

Unable to access req.user server side #6

megmatty opened this issue Nov 18, 2017 · 1 comment

Comments

@megmatty
Copy link

Tried several things, how do I get access to req.user on the server side once logged in?
Trying to save data to database with a user id attached to it, but can't get the user id.

@oampo
Copy link
Contributor

oampo commented Nov 20, 2017

You should have access to req.user as long as the endpoints are protected by the JWT strategy. For example:

app.get('/some-resource',
    passport.authenticate('jwt'), // The middleware both protects you endpoint, and sets req.user
    (req, res) => {
        console.log(req.user);
        res.json({foo: 'bar'});
    }
);

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