|
|
@ -1,6 +1,6 @@ |
|
|
|
import { promisify } from 'util'; |
|
|
|
import { promisify } from 'util'; |
|
|
|
import { Injectable } from '@nestjs/common'; |
|
|
|
import { Injectable } from '@nestjs/common'; |
|
|
|
import { OrgUserRoles, validatePassword } from 'nocodb-sdk'; |
|
|
|
import { AuditOperationSubTypes, AuditOperationTypes, OrgUserRoles, validatePassword } from 'nocodb-sdk' |
|
|
|
import { v4 as uuidv4 } from 'uuid'; |
|
|
|
import { v4 as uuidv4 } from 'uuid'; |
|
|
|
import { isEmail } from 'validator'; |
|
|
|
import { isEmail } from 'validator'; |
|
|
|
import { T } from 'nc-help'; |
|
|
|
import { T } from 'nc-help'; |
|
|
@ -145,10 +145,10 @@ export class UsersService { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
await Audit.insert({ |
|
|
|
await Audit.insert({ |
|
|
|
op_type: 'AUTHENTICATION', |
|
|
|
op_type: AuditOperationTypes.AUTHENTICATION, |
|
|
|
op_sub_type: 'PASSWORD_CHANGE', |
|
|
|
op_sub_type: AuditOperationSubTypes.PASSWORD_CHANGE, |
|
|
|
user: user.email, |
|
|
|
user: user.email, |
|
|
|
description: `changed password `, |
|
|
|
description: `Password has been changed`, |
|
|
|
ip: param.req?.clientIp, |
|
|
|
ip: param.req?.clientIp, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -203,10 +203,10 @@ export class UsersService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await Audit.insert({ |
|
|
|
await Audit.insert({ |
|
|
|
op_type: 'AUTHENTICATION', |
|
|
|
op_type: AuditOperationTypes.AUTHENTICATION, |
|
|
|
op_sub_type: 'PASSWORD_FORGOT', |
|
|
|
op_sub_type: AuditOperationSubTypes.PASSWORD_FORGOT, |
|
|
|
user: user.email, |
|
|
|
user: user.email, |
|
|
|
description: `requested for password reset `, |
|
|
|
description: `Password Reset has been requested`, |
|
|
|
ip: param.req?.clientIp, |
|
|
|
ip: param.req?.clientIp, |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -279,10 +279,10 @@ export class UsersService { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
await Audit.insert({ |
|
|
|
await Audit.insert({ |
|
|
|
op_type: 'AUTHENTICATION', |
|
|
|
op_type: AuditOperationTypes.AUTHENTICATION, |
|
|
|
op_sub_type: 'PASSWORD_RESET', |
|
|
|
op_sub_type: AuditOperationSubTypes.PASSWORD_RESET, |
|
|
|
user: user.email, |
|
|
|
user: user.email, |
|
|
|
description: `did reset password `, |
|
|
|
description: `Password has been reset`, |
|
|
|
ip: req.clientIp, |
|
|
|
ip: req.clientIp, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -311,10 +311,10 @@ export class UsersService { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
await Audit.insert({ |
|
|
|
await Audit.insert({ |
|
|
|
op_type: 'AUTHENTICATION', |
|
|
|
op_type: AuditOperationTypes.AUTHENTICATION, |
|
|
|
op_sub_type: 'EMAIL_VERIFICATION', |
|
|
|
op_sub_type: AuditOperationSubTypes.EMAIL_VERIFICATION, |
|
|
|
user: user.email, |
|
|
|
user: user.email, |
|
|
|
description: `verified email `, |
|
|
|
description: `Email has been verified`, |
|
|
|
ip: req.clientIp, |
|
|
|
ip: req.clientIp, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -466,10 +466,10 @@ export class UsersService { |
|
|
|
setTokenCookie(param.res, refreshToken); |
|
|
|
setTokenCookie(param.res, refreshToken); |
|
|
|
|
|
|
|
|
|
|
|
await Audit.insert({ |
|
|
|
await Audit.insert({ |
|
|
|
op_type: 'AUTHENTICATION', |
|
|
|
op_type: AuditOperationTypes.AUTHENTICATION, |
|
|
|
op_sub_type: 'SIGNUP', |
|
|
|
op_sub_type: AuditOperationSubTypes.SIGNUP, |
|
|
|
user: user.email, |
|
|
|
user: user.email, |
|
|
|
description: `signed up `, |
|
|
|
description: `User has signed up`, |
|
|
|
ip: (param.req as any).clientIp, |
|
|
|
ip: (param.req as any).clientIp, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -482,10 +482,7 @@ export class UsersService { |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async signout(param: { |
|
|
|
async signout(param: { res: any; req: any }) { |
|
|
|
req: any, |
|
|
|
|
|
|
|
res: any, |
|
|
|
|
|
|
|
}) { |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
param.res.clearCookie('refresh_token'); |
|
|
|
param.res.clearCookie('refresh_token'); |
|
|
|
const user = (param.req as any).user; |
|
|
|
const user = (param.req as any).user; |
|
|
|