index.js
842 Bytes
const models = require('../models/index');
const localStrategy = require('./localStrategy');
module.exports = (passport) => {
passport.serializeUser((user, done) => {
done(null, user.email);
});
passport.deserializeUser(async (email, done) => {
try {
const user = await models.User.findOne({
where: {email},
attributes: ['id', 'email', 'nickName']
});
if (!user) {
console.error('유저 데이터가 존재하지 않습니다.');
done(null, false, {message: '유저 데이터가 존재하지 않습니다.'});
}
return done(null, user);
} catch (e) {
console.error(e);
done(e);
}
});
localStrategy(passport);
};