Skip to content

Commit

Permalink
Changes to passport
Browse files Browse the repository at this point in the history
  • Loading branch information
StraightUpCode committed Jun 5, 2020
1 parent 4813635 commit 6541749
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions auth/passport.mjs
Expand Up @@ -8,11 +8,16 @@ passport.use(
new LocalStrategy(async (username, password, done) => {
console.log('Username',username)
console.log('Password',password)
try{
const user = await UserModel.findOne({
where: {
username : username,
}
})
}catch(e){
console.log(e)
return done(null,false, 'Wrong Credentials' )
}
if(! user ){
console.log('No existe el user')
return done(null,false, 'Wrong Credentials' )
Expand All @@ -33,9 +38,13 @@ passport.serializeUser((user, done) => {
})

passport.deserializeUser(async (userId,done) => {
try{
const user = await UserModel.findByPk(userId)
console.log('Deserialize', user)
done(null,user)
}catch(e){
console.log(e)
}
})

export default passport

0 comments on commit 6541749

Please sign in to comment.