How to make two different serialize and deserialize methods in Node js, with Passport?

Asked

Viewed 64 times

0

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

The problem is when I will do the second login, because there is no way to modify the passport.serializeUser and the passport.deserializeUser with the id of the second login and the MYSQL table of the second login also.

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 doubt where they’re called, I’ve searched my code and I can’t find it. To be honest, I’m new to Ode 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 modify it here.

  • Take a look here, related: http://answall.com/q/86609/129

  • So I took a look at that, but my problem is in relation to two different user logins, you know? But thanks anyway!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.