V
V
vosyukov2017-02-07 18:59:54
JSON Web Token
vosyukov, 2017-02-07 18:59:54

How to correctly check if a user is logged in to passport-jwt?

passport.use(new JwtStrategy(opts, function(jwt_payload, done) {
    User.findUserById(jwt_payload.id)
        .then(function(user) {
            return done(null, user);
        })
        .catch(function(err){
            return done(err, false);
        })
}));

There is such a strategy, tell me if it is correct to check if there is a user in the database with each request?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question