summaryrefslogtreecommitdiffstats
path: root/server/lib/log.js
diff options
context:
space:
mode:
authorJannik Schönartz2019-12-01 16:03:55 +0100
committerJannik Schönartz2019-12-01 16:03:55 +0100
commitdc25bd7de72aa574767876341e5792733c2ee0e0 (patch)
tree4086f19a6df107773a3990c422fe1160f8959147 /server/lib/log.js
parent[configloader] bugfixes in the beta configloader: (diff)
downloadbas-dc25bd7de72aa574767876341e5792733c2ee0e0.tar.gz
bas-dc25bd7de72aa574767876341e5792733c2ee0e0.tar.xz
bas-dc25bd7de72aa574767876341e5792733c2ee0e0.zip
[server/log] Add logging to all modules
Logging with snapshots: Client: create / edit / delete / added to group / removed from group Group: create / edit / delete / added to group / removed from group Logging without snapshot: Wake-on-lan: wakup Ipxe-Builder: build / clear / cancel / script save IP-Ranges: create / edit / delete Logging: with info in description: User: create / edit / delete / grant role / revoke role Event: create / edit / delete Permission-Manager-Role: create / edit / delete Registration-Hook: create / delete / edit / change order Ipxe Configuration: create / delete / edit Backend: create / edit / delete
Diffstat (limited to 'server/lib/log.js')
-rw-r--r--server/lib/log.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/server/lib/log.js b/server/lib/log.js
index fede874..782c34f 100644
--- a/server/lib/log.js
+++ b/server/lib/log.js
@@ -2,7 +2,7 @@
const path = require('path')
var db = require(path.join(__appdir, 'lib', 'sequelize'))
-async function log ({ category, description, groupId, clientId, userId }) {
+async function log ({ category, description, clientId, userId, groupId, group, client, user }) {
const entry = db.log.build({
category,
description,
@@ -11,9 +11,14 @@ async function log ({ category, description, groupId, clientId, userId }) {
clientId,
userId
})
- if (groupId) entry.groupSnapshot = JSON.stringify(await db.group.findOne({ where: { id: groupId } }))
- if (clientId) entry.clientSnapshot = JSON.stringify(await db.client.findOne({ where: { id: clientId } }))
- if (userId) entry.userSnapshot = JSON.stringify(await db.user.findOne({ where: { id: userId } }))
+
+ if (group) entry.groupSnapshot = JSON.stringify(group)
+ else if (groupId) entry.groupSnapshot = JSON.stringify(await db.group.findOne({ where: { id: groupId } }))
+ if (client) entry.clientSnapshot = JSON.stringify(client)
+ else if (clientId) entry.clientSnapshot = JSON.stringify(await db.client.findOne({ where: { id: clientId } }))
+ if (user) entry.userSnapshot = JSON.stringify(user)
+ else if (userId) entry.userSnapshot = JSON.stringify(await db.user.findOne({ where: { id: userId } }))
+
await entry.save()
return entry
}