mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Auth logging prettying
This commit is contained in:
parent
fa4b29efe6
commit
9a6553dbbb
3 changed files with 10 additions and 4 deletions
|
@ -25,13 +25,15 @@ module.exports = function (options) {
|
|||
return req.url.split('?')[0] === exc
|
||||
})
|
||||
|
||||
// TODO Allowing all urls with _next in it, but not in params
|
||||
// FIXME Allowing all urls with _next in it, but not in params
|
||||
if (req.url.split('?')[0].includes('_next')) {
|
||||
req.session = { isException: true }
|
||||
next()
|
||||
return
|
||||
}
|
||||
|
||||
if (isException) {
|
||||
req.session = { isException: true }
|
||||
logger.DebugLog(`EXCEPTION: ${req.url}`, 'auth', 1)
|
||||
next()
|
||||
return
|
||||
|
|
|
@ -245,7 +245,7 @@ function GetApp () {
|
|||
})
|
||||
|
||||
if (existingSessions.length > 0) {
|
||||
logger.Log(`Multiple sessions ( ${existingSessions.length} ) for #${user.id}, deleting olds`, logger.GetColor('cyan'))
|
||||
logger.Log(`Multiple ${isScript ? 'script' : 'website'} sessions ( ${existingSessions.length} ) for #${user.id}, deleting olds`, logger.GetColor('cyan'))
|
||||
existingSessions.forEach((sess) => {
|
||||
dbtools.Delete(userDB, 'sessions', {
|
||||
id: sess.id,
|
||||
|
@ -284,9 +284,9 @@ function GetApp () {
|
|||
result: 'success',
|
||||
msg: 'you are now logged in'
|
||||
})
|
||||
logger.Log(`Successfull login with user ID: #${user.id}`, logger.GetColor('cyan'))
|
||||
logger.Log(`Successfull login to ${isScript ? 'script' : 'website'} with user ID: #${user.id}`, logger.GetColor('cyan'))
|
||||
} else {
|
||||
logger.Log(`Login attempt with invalid pw: ${pw}`, logger.GetColor('cyan'))
|
||||
logger.Log(`Login attempt with invalid pw: ${pw} to ${isScript ? 'script' : 'website'}`, logger.GetColor('cyan'))
|
||||
res.json({
|
||||
result: 'error',
|
||||
msg: 'Invalid password'
|
||||
|
|
|
@ -127,6 +127,10 @@ function LogReq (req, toFile, sc) {
|
|||
|
||||
if (req.session && req.session.user) {
|
||||
logEntry += C('cyan') + req.session.user.id + C() + dl
|
||||
} else if (req.session && req.session.isException === true) {
|
||||
logEntry += C('cyan') + 'EX' + C() + dl
|
||||
} else {
|
||||
logEntry += C('red') + 'NOUSER' + C() + dl
|
||||
}
|
||||
|
||||
logEntry += GetRandomColor(req.url.split('?')[0]) + req.url
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue