Skip to content

Commit 15c1769

Browse files
committed
feat: added verbose logging for admin add action
1 parent 8ec3bd0 commit 15c1769

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

core/routes/adminManager/actions.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ async function handleAdd(ctx: AuthedCtx) {
8080
}
8181

8282
//Validate & translate FiveM ID
83-
let citizenfxData: ProviderDataType | undefined;
83+
let citizenfxData: ProviderDataType | false = false;
8484
if (citizenfxID.length) {
8585
try {
8686
if (consts.validIdentifiers.fivem.test(citizenfxID)) {
@@ -111,7 +111,7 @@ async function handleAdd(ctx: AuthedCtx) {
111111
}
112112

113113
//Validate Discord ID
114-
let discordData: ProviderDataType | undefined;
114+
let discordData: ProviderDataType | false = false;
115115
if (discordID.length) {
116116
if (!consts.validIdentifierParts.discord.test(discordID)) {
117117
return ctx.send({ type: 'danger', message: 'Invalid Discord ID' });
@@ -133,10 +133,17 @@ async function handleAdd(ctx: AuthedCtx) {
133133
}
134134
}
135135

136+
//List changes
137+
const changes = {
138+
cfxId: citizenfxData ? citizenfxData.identifier : undefined,
139+
discordId: discordData ? discordData.identifier : undefined,
140+
permissions: permissions,
141+
};
142+
136143
//Add admin and give output
137144
try {
138145
await txCore.adminStore.addAdmin(name, citizenfxData, discordData, password, permissions);
139-
ctx.admin.logAction(`Adding user '${name}'.`);
146+
ctx.admin.logAction(`Adding user '${name}' with ${JSON.stringify(changes)}`);
140147
return ctx.send({ type: 'showPassword', password });
141148
} catch (error) {
142149
return ctx.send({ type: 'danger', message: (error as Error).message });

0 commit comments

Comments
 (0)