fix: sqlite migrations

This commit is contained in:
Nick
2019-02-22 17:05:18 -05:00
parent fefd60a356
commit 3743777b97
10 changed files with 440 additions and 49 deletions

View File

@@ -12,30 +12,28 @@ module.exports = {
new LocalStrategy({
usernameField: 'email',
passwordField: 'password'
}, (uEmail, uPassword, done) => {
WIKI.models.users.query().findOne({
email: uEmail,
providerKey: 'local'
}).then((user) => {
}, async (uEmail, uPassword, done) => {
try {
const user = await WIKI.models.users.query().findOne({
email: uEmail,
providerKey: 'local'
})
if (user) {
return user.verifyPassword(uPassword).then(() => {
if (!user.isActive) {
done(new WIKI.Error.AuthAccountBanned(), null)
} else if (!user.isVerified) {
done(new WIKI.Error.AuthAccountNotVerified(), null)
} else {
done(null, user)
}
}).catch((err) => {
done(err, null)
})
await user.verifyPassword(uPassword)
if (!user.isActive) {
done(new WIKI.Error.AuthAccountBanned(), null)
} else if (!user.isVerified) {
done(new WIKI.Error.AuthAccountNotVerified(), null)
} else {
done(null, user)
}
} else {
done(new WIKI.Error.AuthLoginFailed(), null)
}
}).catch((err) => {
} catch (err) {
done(err, null)
})
}
))
}
})
)
}
}