How to do two different serialize and deserialize methods on node js, with passport?

0

I have two different user types in my application. I was able to log in to one of the two users using the passport with serialize and deserialize.

The problem is when I am going to make the second login, because there is no way to modify the passport.serializeUser and passport.deserializeUser with the second login id and MYSQL table of the second login as well.

passport.serializeUser(function(user, done) {
    done(null, user.id_user);
});


passport.deserializeUser(function(id, done) {
    connection.query("SELECT * FROM usuario WHERE id_user = ? ",[id], function(err, rows){
        done(err, rows[0]);
    });
});

I have doubts on where they are called, searched in my code and I can not find it. To be honest, I'm new to node and I've never worked with these methods before, so it's pretty confusing for me. If you need any other part of the code I'll edit it here.

    
asked by anonymous 06.05.2016 / 15:40

0 answers