@memberjunction/server 0.9.251 → 0.9.253

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -271,19 +271,33 @@ export class ResolverBase {
271
271
  if (!userInfo) throw new Error(`User ${userPayload?.email} not found in metadata`);
272
272
  if (!auditLogType) throw new Error(`Audit Log Type ${auditLogTypeName} not found in metadata`);
273
273
 
274
- const auditLog = <AuditLogEntity>await md.GetEntityObject('Audit Logs', userInfo); // must pass user context on back end as we're not authenticated the same way as the front end
274
+ const auditLog = await md.GetEntityObject<AuditLogEntity>('Audit Logs', userInfo); // must pass user context on back end as we're not authenticated the same way as the front end
275
275
  auditLog.NewRecord();
276
276
  auditLog.UserID = userInfo.ID;
277
277
  auditLog.AuditLogTypeName = auditLogType.Name;
278
- if (authorization) auditLog.AuthorizationName = authorization.Name;
279
- auditLog.Status = status;
280
- if (details) auditLog.Details = details;
278
+
279
+ if (authorization)
280
+ auditLog.AuthorizationName = authorization.Name;
281
+
282
+ if (status?.trim().toLowerCase() === 'success')
283
+ auditLog.Status = "Success"
284
+ else
285
+ auditLog.Status = "Failed";
286
+
287
+ if (details)
288
+ auditLog.Details = details;
289
+
281
290
  auditLog.EntityID = entityId;
282
- if (recordId) auditLog.RecordID = recordId;
283
291
 
284
- if (await auditLog.Save()) return auditLog;
285
- else throw new Error(`Error saving audit log record`);
286
- } catch (err) {
292
+ if (recordId)
293
+ auditLog.RecordID = recordId;
294
+
295
+ if (await auditLog.Save())
296
+ return auditLog;
297
+ else
298
+ throw new Error(`Error saving audit log record`);
299
+ }
300
+ catch (err) {
287
301
  console.log(err);
288
302
  return null;
289
303
  }