Closed ViolentCrumble closed 6 years ago
ok i think i have solved this.
Was a pain due to very littly docs on the subject on the passport.js website.
I believe the issue came down to how i was serialising and deserialising the user.
i updated my code to use email and now it seems to work.
passport.serializeUser(function(user, done) {
done(null, user.email);
});
passport.deserializeUser(function(email, done) {
User.findOne({email: email}, function(err, user) {
done(err, user);
});
});
Hi so i'm not sure if i'm doing something wrong but there seems to be an issue when trying to use local passport and also passport discord.
If i log in with passport discord it seems to search by discord username and auth that user, regardless of the actual user.
So since usernames are not unique on discord this is not good at all.
It will auth the user correctly and create the user in the database but seems to be logging in with the wrong user.
Is it possible to use this combined with local strategy?
code below
app.js
route
user model
The idea being i do not wish for usernames to be unique on the website, rather emails are what is used.
With this, I can authenticate fine with discord but once it has authenticated it will be logged in as whatever user has the same username as the auth'd user. Which if there are other users with the same username it will pick the first one.
Any advice would be appreciated. I have been dealing with this all day