-
Notifications
You must be signed in to change notification settings - Fork 0
/
passport.js
31 lines (30 loc) · 888 Bytes
/
passport.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// user auth
const passport = require('passport');
const LocalStrategy = require('passport-local').Strategy;
const Employees = require('./models/employee');
// passport config
// passport.use(Employees.createStrategy());
passport.use(new LocalStrategy(Employees.authenticate()));
// passport.use(new LocalStrategy(
// {
// usernameField: 'username',
// passwordField: 'password',
// },
// (username, password, done) => {
// User.findOne({
// username: username,
// }, (error, user) => {
// if (error) {
// return done(error);
// }
// if (!user) {
// return done(null, false, {
// message: 'Username or password incorrect',
// });
// }
// return done(null, user);
// });
// },
// ));
passport.serializeUser(Employees.serializeUser());
passport.deserializeUser(Employees.deserializeUser());