Db structure changes

This commit is contained in:
mrfry 2021-05-12 10:15:32 +02:00
parent 6eef9fd1c0
commit bf2f63e810
6 changed files with 19 additions and 93 deletions

View file

@ -92,8 +92,6 @@ export default function (options: Options): any {
logger.DebugLog(`ID #${user.id}: ${req.url}`, 'auth', 1)
UpdateAccess(userDB, user, sessionID)
dbtools.Update(
userDB,
'sessions',
@ -109,7 +107,6 @@ export default function (options: Options): any {
userDB,
'users',
{
lastIP: '0.0.0.0',
lastAccess: utils.GetDateString(),
},
{
@ -121,22 +118,6 @@ export default function (options: Options): any {
}
}
function UpdateAccess(db, user, sessionID) {
const accesses = dbtools.Select(db, 'accesses', {
userId: user.id,
ip: '0.0.0.0',
})
if (accesses.length === 0) {
dbtools.Insert(db, 'accesses', {
userID: user.id,
ip: '0.0.0.0',
sessionID: sessionID,
date: utils.GetDateString(),
})
}
}
function GetUserBySessionID(db: any, sessionID: string) {
logger.DebugLog(`Getting user from db`, 'auth', 2)

View file

@ -7,14 +7,14 @@ interface Options {
excludeFromStats: Array<string>
}
export default function(options: Options): any {
export default function (options: Options): any {
const loggableKeywords = options ? options.loggableKeywords : undefined
const loggableModules = options ? options.loggableModules : undefined
const exceptions = options.exceptions || []
const excludeFromStats = options.excludeFromStats || []
return function(req, res, next) {
res.on('finish', function() {
return function (req, res, next) {
res.on('finish', function () {
// TODO: test this
const isException = exceptions.some((ex) => {
return req.url.includes(ex)