Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- passport.use(
- new LocalStrategy(
- {
- usernameField: 'email',
- passwordField: 'password',
- },
- async (email, password, done) => {
- let user = null;
- await getAsync('usersMockDatabase').then((users) => {
- const currUsers = JSON.parse(users);
- user = currUsers.find(currUser => currUser.email === email);
- });
- if (!user) {
- done({ type: 'email', message: 'No such user found' }, false);
- return;
- }
- if (bcrypt.compareSync(password, user.password)) {
- done(null, { id: user.id, email: user.email, userName: user.userName });
- } else {
- done({ type: 'password', message: 'Passwords did not match' }, false);
- }
- },
- ),
- );
Add Comment
Please, Sign In to add comment