Feat: adds async local storage to admin server

This commit is contained in:
csrapr 2021-05-24 21:57:39 +01:00 committed by Sérgio Salgado
parent 8128f05ffb
commit cb2e1b3907
5 changed files with 47 additions and 8 deletions

View file

@ -30,8 +30,7 @@ const authenticateUser = (username, password) => {
const destroySessionIfSameUser = (context, user) => {
const sessionUser = getUserFromCookie(context)
if (sessionUser && user.id === sessionUser.id)
context.req.session.destroy()
if (sessionUser && user.id === sessionUser.id) { context.req.session.destroy() }
}
const destroySessionIfBeingUsed = (sessID, context) => {
@ -60,7 +59,7 @@ const executeProtectedAction = (code, id, context, action) => {
if (user.role !== 'superuser') {
return action()
}
return confirm2FA(code, context)
.then(() => action())
})