Browse Source

refactor(nocodb): revise audit description

pull/5403/head
Wing-Kam Wong 2 years ago
parent
commit
82b73b140d
  1. 4
      packages/nocodb/src/lib/controllers/user/user.ctl.ts
  2. 26
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts
  3. 2
      packages/nocodb/src/lib/services/audit.svc.ts
  4. 6
      packages/nocodb/src/lib/services/column.svc.ts
  5. 4
      packages/nocodb/src/lib/services/orgUser.svc.ts
  6. 6
      packages/nocodb/src/lib/services/projectUser.svc.ts
  7. 2
      packages/nocodb/src/lib/services/table.svc.ts
  8. 10
      packages/nocodb/src/lib/services/user/index.ts

4
packages/nocodb/src/lib/controllers/user/user.ctl.ts

@ -93,7 +93,7 @@ async function signin(req, res, next) {
info,
req,
res,
auditDescription: 'signed in',
auditDescription: 'User has signed in successfully',
})
)(req, res, next);
}
@ -112,7 +112,7 @@ async function googleSignin(req, res, next) {
info,
req,
res,
auditDescription: 'signed in using Google Auth',
auditDescription: 'User has signed in successfully using Google Auth ',
})
)(req, res, next);
}

26
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

@ -2296,7 +2296,7 @@ class BaseModelSqlv2 {
op_type: AuditOperationTypes.DATA,
op_sub_type: AuditOperationSubTypes.INSERT,
description: DOMPurify.sanitize(
`${id} inserted into ${this.model.title}`
`Record with ID ${id} has been inserted into Table ${this.model.title}`
),
// details: JSON.stringify(data),
ip: req?.clientIp,
@ -2322,7 +2322,9 @@ class BaseModelSqlv2 {
op_type: AuditOperationTypes.DATA,
op_sub_type: AuditOperationSubTypes.BULK_UPDATE,
description: DOMPurify.sanitize(
`${noOfUpdatedRecords} records bulk updated in ${this.model.title}`
`${noOfUpdatedRecords} ${
noOfUpdatedRecords > 1 ? 'records have' : 'record has'
} been bulk updated in ${this.model.title}`
),
// details: JSON.stringify(data),
ip: req?.clientIp,
@ -2347,7 +2349,9 @@ class BaseModelSqlv2 {
op_type: AuditOperationTypes.DATA,
op_sub_type: AuditOperationSubTypes.BULK_DELETE,
description: DOMPurify.sanitize(
`${noOfDeletedRecords} records bulk deleted in ${this.model.title}`
`${noOfDeletedRecords} ${
noOfDeletedRecords > 1 ? 'records have' : 'record has'
} been bulk deleted in ${this.model.title}`
),
// details: JSON.stringify(data),
ip: req?.clientIp,
@ -2363,7 +2367,9 @@ class BaseModelSqlv2 {
op_type: AuditOperationTypes.DATA,
op_sub_type: AuditOperationSubTypes.BULK_INSERT,
description: DOMPurify.sanitize(
`${data.length} records bulk inserted into ${this.model.title}`
`${data.length} ${
data.length > 1 ? 'records have' : 'record has'
} been bulk inserted in ${this.model.title}`
),
// details: JSON.stringify(data),
ip: req?.clientIp,
@ -2396,7 +2402,9 @@ class BaseModelSqlv2 {
row_id: id,
op_type: AuditOperationTypes.DATA,
op_sub_type: AuditOperationSubTypes.UPDATE,
description: DOMPurify.sanitize(`${id} updated in ${this.model.title}`),
description: DOMPurify.sanitize(
`Record with ID ${id} has been updated in Table ${this.model.title}`
),
// details: JSON.stringify(data),
ip: req?.clientIp,
user: req?.user?.email,
@ -2424,7 +2432,9 @@ class BaseModelSqlv2 {
row_id: id,
op_type: AuditOperationTypes.DATA,
op_sub_type: AuditOperationSubTypes.DELETE,
description: DOMPurify.sanitize(`${id} deleted from ${this.model.title}`),
description: DOMPurify.sanitize(
`Record with ID ${id} has been deleted in Table ${this.model.title}`
),
// details: JSON.stringify(data),
ip: req?.clientIp,
user: req?.user?.email,
@ -2695,7 +2705,7 @@ class BaseModelSqlv2 {
op_sub_type: AuditOperationSubTypes.LINK_RECORD,
row_id: rowId,
description: DOMPurify.sanitize(
`Record [id:${childId}] record linked with record [id:${rowId}] record in ${this.model.title}`
`Record [id:${childId}] has been linked with record [id:${rowId}] in ${this.model.title}`
),
// details: JSON.stringify(data),
ip: req?.clientIp,
@ -2797,7 +2807,7 @@ class BaseModelSqlv2 {
op_sub_type: AuditOperationSubTypes.UNLINK_RECORD,
row_id: rowId,
description: DOMPurify.sanitize(
`Record [id:${childId}] record unlinked with record [id:${rowId}] record in ${this.model.title}`
`Record [id:${childId}] has been unlinked with record [id:${rowId}] in ${this.model.title}`
),
// details: JSON.stringify(data),
ip: req?.clientIp,

2
packages/nocodb/src/lib/services/audit.svc.ts

@ -36,7 +36,7 @@ export async function auditRowUpdate(param: {
op_type: AuditOperationTypes.DATA,
op_sub_type: AuditOperationSubTypes.UPDATE,
description: DOMPurify.sanitize(
`Table ${model.table_name} : field ${param.body.column_name} got changed from ${param.body.prev_value} to ${param.body.value}`
`The column ${param.body.column_name} in Table ${model.table_name} has been changed from ${param.body.prev_value} to ${param.body.value}`
),
details: DOMPurify.sanitize(`<span class="">${param.body.column_name}</span>
: <span class="text-decoration-line-through red px-2 lighten-4 black--text">${param.body.prev_value}</span>

6
packages/nocodb/src/lib/services/column.svc.ts

@ -824,7 +824,7 @@ export async function columnUpdate(param: {
op_type: AuditOperationTypes.TABLE_COLUMN,
op_sub_type: AuditOperationSubTypes.UPDATE,
user: param.req?.user?.email,
description: `updated column ${column.column_name} with alias ${column.title} from table ${table.table_name}`,
description: `The column ${column.column_name} with alias ${column.title} from table ${table.table_name} has been updated`,
ip: param.req?.clientIp,
}).then(() => {});
@ -1129,7 +1129,7 @@ export async function columnAdd(param: {
op_type: AuditOperationTypes.TABLE_COLUMN,
op_sub_type: AuditOperationSubTypes.CREATE,
user: param?.req.user?.email,
description: `created column ${colBody.column_name} with alias ${colBody.title} from table ${table.table_name}`,
description: `The column ${colBody.column_name} with alias ${colBody.title} from table ${table.table_name} has been created`,
ip: param?.req.clientIp,
}).then(() => {});
@ -1341,7 +1341,7 @@ export async function columnDelete(param: { req?: any; columnId: string }) {
op_type: AuditOperationTypes.TABLE_COLUMN,
op_sub_type: AuditOperationSubTypes.DELETE,
user: param?.req?.user?.email,
description: `deleted column ${column.column_name} with alias ${column.title} from table ${table.table_name}`,
description: `The column ${column.column_name} with alias ${column.title} from table ${table.table_name} has been deleted`,
ip: param?.req.clientIp,
}).then(() => {});

4
packages/nocodb/src/lib/services/orgUser.svc.ts

@ -147,7 +147,7 @@ export async function userAdd(param: {
op_type: AuditOperationTypes.ORG_USER,
op_sub_type: AuditOperationSubTypes.INVITE,
user: param.req.user.email,
description: `invited ${email} to ${param.projectId} project `,
description: `${email} has been invited to ${param.projectId} project`,
ip: param.req.clientIp,
});
// in case of single user check for smtp failure
@ -218,7 +218,7 @@ export async function userInviteResend(param: {
op_type: AuditOperationTypes.ORG_USER,
op_sub_type: AuditOperationSubTypes.RESEND_INVITE,
user: user.email,
description: `resent a invite to ${user.email} `,
description: `${user.email} has been re-invited`,
ip: param.req.clientIp,
});

6
packages/nocodb/src/lib/services/projectUser.svc.ts

@ -98,7 +98,7 @@ export async function userInvite(param: {
op_type: AuditOperationTypes.AUTHENTICATION,
op_sub_type: AuditOperationSubTypes.INVITE,
user: param.req.user.email,
description: `invited ${email} to ${param.projectId} project `,
description: `${email} has been invited to ${param.projectId} project`,
ip: param.req.clientIp,
});
} else {
@ -209,7 +209,7 @@ export async function projectUserUpdate(param: {
op_type: AuditOperationTypes.AUTHENTICATION,
op_sub_type: AuditOperationSubTypes.ROLES_MANAGEMENT,
user: param.req.user.email,
description: `updated roles for ${user.email} with ${param.projectUser.roles} `,
description: `Roles for ${user.email} with has been updated to ${param.projectUser.roles}`,
ip: param.req.clientIp,
});
@ -281,7 +281,7 @@ export async function projectUserInviteResend(param: {
op_type: AuditOperationTypes.AUTHENTICATION,
op_sub_type: AuditOperationSubTypes.RESEND_INVITE,
user: user.email,
description: `resent a invite to ${user.email} `,
description: `${user.email} has been re-invited`,
ip: param.req.clientIp,
project_id: param.projectId,
});

2
packages/nocodb/src/lib/services/table.svc.ts

@ -435,7 +435,7 @@ export async function tableCreate(param: {
op_type: AuditOperationTypes.TABLE,
op_sub_type: AuditOperationSubTypes.CREATE,
user: param.user?.email,
description: `created table ${tableCreatePayLoad.table_name} with alias ${tableCreatePayLoad.title} `,
description: `Table ${tableCreatePayLoad.table_name} with alias ${tableCreatePayLoad.title} has been created`,
ip: param.req?.clientIp,
}).then(() => {});

10
packages/nocodb/src/lib/services/user/index.ts

@ -127,7 +127,7 @@ export async function passwordChange(param: {
op_type: AuditOperationTypes.AUTHENTICATION,
op_sub_type: AuditOperationSubTypes.PASSWORD_CHANGE,
user: user.email,
description: `changed password `,
description: `Password has been changed`,
ip: param.req?.clientIp,
});
@ -185,7 +185,7 @@ export async function passwordForgot(param: {
op_type: AuditOperationTypes.AUTHENTICATION,
op_sub_type: AuditOperationSubTypes.PASSWORD_FORGOT,
user: user.email,
description: `requested for password reset `,
description: `Password Reset has been requested`,
ip: param.req?.clientIp,
});
} else {
@ -261,7 +261,7 @@ export async function passwordReset(param: {
op_type: AuditOperationTypes.AUTHENTICATION,
op_sub_type: AuditOperationSubTypes.PASSWORD_RESET,
user: user.email,
description: `did reset password `,
description: `Password has been reset`,
ip: req.clientIp,
});
@ -293,7 +293,7 @@ export async function emailVerification(param: {
op_type: AuditOperationTypes.AUTHENTICATION,
op_sub_type: AuditOperationSubTypes.EMAIL_VERIFICATION,
user: user.email,
description: `verified email `,
description: `Email has been verified`,
ip: req.clientIp,
});
@ -449,7 +449,7 @@ export async function signup(param: {
op_type: AuditOperationTypes.AUTHENTICATION,
op_sub_type: AuditOperationSubTypes.SIGNUP,
user: user.email,
description: `signed up `,
description: `User has signed up`,
ip: (param.req as any).clientIp,
});

Loading…
Cancel
Save