Merge pull request #276 from memphisdj/fix-user-no-password-login

Fix user no password login and cookie maxAge extension
This commit is contained in:
KodeStar 2021-04-14 15:00:35 +01:00 committed by GitHub
commit aa721a3412
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26952 additions and 40 deletions

View File

@ -12,8 +12,9 @@ module.exports = {
if (user && !req.originalUrl.match(/\/logout/)) {
// Extend the tokens life while the user is browsing
const token = user.generateJWT()
const domain = req.hostname === 'localhost' ? 'localhost' : `.${req.hostname.split('.').slice(-2).join('.')}` // Set cookie on top level domain for auth proxying
res.cookie('jwt', token, {
domain: `.${req.host.split('.').slice(-2).join('.')}`, // Set cookie on top level domain for auth proxying
domain: domain,
maxAge: 3600000
})
}

26969
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -28,17 +28,26 @@ router.post(
})
}
if (req.body.username === undefined) {
return res.status(403).json({
status: 'error',
result: 'No username provided!'
})
}
const user = await User.findOne({
where: {
username: req.body.username
}
})
if (!user || !user.verifyPassword(req.body.password)) {
return res.status(403).json({
status: 'error',
result: 'invalid_user'
})
if (req.body.username && req.body.password) {
if (!user || !user.verifyPassword(req.body.password)) {
return res.status(403).json({
status: 'error',
result: 'invalid_user'
})
}
}
if (user.multifactorEnabled && !req.body.totp) {

View File

@ -218,5 +218,4 @@ export async function logout(context) {
// console.log(data)
await axios.get(process.env.BACKEND_LOCATION + 'logout')
context.commit('logout')
this.$router.push('/')
}