I am using sails js v1.0. I am not getting way to how I call passport's authenticate function. Since req, res and next is not there in sails new controller type (action2).
I want to use a passport JWT based auth in sails js v1 app.
fn: async function (inputs, exits) {
passport.authenticate('jwt', {session: false}, (err, user, info) => {
})(inputs, exits);
}
my config/passport.js looks like
passport.use('jwt', new JWTStrategy(opts, (jwtPayload, done) => {
//find the user in db if needed. This functionality may be omitted if you store everything you'll need in JWT payload.
User.findOne({email: jwtPayload.email}).then(async (err, user) => {
if (err) {
return done(err, false);
}
if (!user) {
return done(null, false, {message: 'Incorrect email.'});
}
const validate = await sails.helpers.checkPassword(inputs.password, userRecord.password);
if(!validate) return done(null, false, { message : 'Wrong Password'});
return done(null, user, { message : 'Logged in Successfully Hola'});
}).catch(err => {
return done(err);
})
}));