everything switched over, time to test

This commit is contained in:
Luke Berndt
2023-03-30 22:31:15 -04:00
parent 5875364502
commit b8e60ab926
14 changed files with 1214 additions and 1024 deletions

View File

@@ -5,34 +5,34 @@
const LocalStrategy = require("passport-local").Strategy;
const User = require("../../models/user");
/*
By default, LocalStrategy expects to find credentials in parameters named username and password.
If your site prefers to name these fields differently, options are available to change the defaults.
*/
/*
By default, LocalStrategy expects to find credentials in parameters named username and password.
If your site prefers to name these fields differently, options are available to change the defaults.
*/
const local = new LocalStrategy({
usernameField: "email"
}, (email, password, done) => {
User.findOne({
$or: [{
email
}, {
local: {
email
}
}]
}, (err, user) => {
if(!user) {
console.error("Auth Error - user not found: " + email);
return done(null, false, { message: `Invalid email or password` })
usernameField: "email"
}, async (email, password, done) => {
console.log(`${email} ${password}`);
const user = await User.findOne({
$or: [{
email
}, {
local: {
email
}
}]
});
if (!user) {
console.error("Auth Error - user not found: " + email);
return done(null, false, { message: `Invalid email or password` })
}
user.comparePassword(password, (err, isMatch) => {
if (isMatch) {
return done(null, user)
} else {
console.error("Auth Error - password mismatch: " + email);
return done(null, false, { message: "Invalid email or password" })
}
user.comparePassword(password, (err, isMatch) => {
if (isMatch) {
return done(null, user)
} else {
console.error("Auth Error - password mismatch: " + email);
return done(null, false, { message: "Invalid email or password" })
}
})
})
})
})
})
module.exports = local;