mirror of
https://github.com/Permissionless-Software-Foundation/ipfs-bch-wallet-consumer.git
synced 2026-09-21 16:52:03 -07:00
Add password validation to passport strategy
This commit is contained in:
+11
-2
@@ -18,12 +18,21 @@ passport.deserializeUser(async (id, done) => {
|
||||
passport.use('local', new Strategy({
|
||||
usernameField: 'username',
|
||||
passwordField: 'password'
|
||||
}, async (email, password, done) => {
|
||||
}, async (username, password, done) => {
|
||||
try {
|
||||
const user = await User.findOne({ email, password })
|
||||
const user = await User.findOne({ username })
|
||||
if(!user) { return done(null, false) }
|
||||
|
||||
try {
|
||||
const isMatch = await user.validatePassword(password)
|
||||
|
||||
if(!isMatch) { return done(null, false) }
|
||||
|
||||
done(null, user)
|
||||
} catch(err) {
|
||||
done(err)
|
||||
}
|
||||
|
||||
} catch(err) {
|
||||
return done(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user