feat: session secret
This commit is contained in:
parent
6396eb8247
commit
6e7794bfc6
2 changed files with 26 additions and 11 deletions
|
|
@ -8,16 +8,19 @@ const sessionManager = require('../../../session-manager')
|
|||
|
||||
const REMEMBER_ME_AGE = 90 * T.day
|
||||
|
||||
async function authenticateUser (username, password) {
|
||||
const hashedPassword = await loginHelper.checkUser(username)
|
||||
if (!hashedPassword) return null
|
||||
|
||||
const isMatch = await bcrypt.compare(password, hashedPassword)
|
||||
if (!isMatch) return null
|
||||
|
||||
const user = await loginHelper.validateUser(username, hashedPassword)
|
||||
if (!user) return null
|
||||
return user
|
||||
function authenticateUser (username, password) {
|
||||
return loginHelper.checkUser(username).then(hashedPassword => {
|
||||
if (!hashedPassword) return null
|
||||
return Promise.all([bcrypt.compare(password, hashedPassword), hashedPassword])
|
||||
}).then(([isMatch, hashedPassword]) => {
|
||||
if (!isMatch) return null
|
||||
return loginHelper.validateUser(username, hashedPassword)
|
||||
}).then(user => {
|
||||
if (!user) return null
|
||||
return user
|
||||
}).catch(e => {
|
||||
console.error(e)
|
||||
})
|
||||
}
|
||||
|
||||
const getUserData = context => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue