I wanted two types of users logging in (User, Client). How exactly can I create localStrategies, serialize and deserialize user for both types in my app.js I have two separa
you need to create two strategy and edit your serialize and deserialize function for support multiple formats When you call authenticate() you can specify startegy name
for example In middleware
exports.authenticateUserA = function (req, res, next) {
console.log('authenticateA', req.body.hostname)
passport.authenticate('loginA', {failureRedirect: '/login-fail',successRedirect: "/home"}, function (err, player, info) {}})
In passport-config.js
passport.serializeUser(function (user, done) {
console.log('deserialize user ')
if (typeof user.mac_address == 'undefined') {
user.data_type = 'userTypeA'
done(null, user);
} else{
user.data_type = 'userTypeB'
done(null, user);
}
});