audit changes

This commit is contained in:
Evert Prants 2022-09-10 09:29:03 +03:00
parent 176fe16b2f
commit eadab90340
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
2 changed files with 9 additions and 4 deletions

View File

@ -7,4 +7,6 @@ export enum AuditAction {
EMAIL_CHANGE = 'email_change',
MALICIOUS_REQUEST = 'malicious_request',
THROTTLE = 'throttle',
DEACTIVATION_REQUEST = 'deactivation_request',
DATA_DOWNLOAD_REQUEST = 'data_download_request',
}

View File

@ -17,6 +17,12 @@ import { AuditSearchClause, UserLoginEntry } from './audit.interfaces';
const PLUCK_LOCATION = ['country', 'city', 'timezone', 'll'];
const PLUCK_USER_AGENT = ['browser', 'version', 'os', 'platform'];
const AUTOFLAG = [
AuditAction.MALICIOUS_REQUEST,
AuditAction.THROTTLE,
AuditAction.DEACTIVATION_REQUEST,
AuditAction.DATA_DOWNLOAD_REQUEST,
];
@Injectable()
export class AuditService {
@ -40,10 +46,7 @@ export class AuditService {
audit.actor_ua = ua;
audit.actor = user;
if (
action === AuditAction.MALICIOUS_REQUEST ||
action === AuditAction.THROTTLE
) {
if (AUTOFLAG.includes(action)) {
audit.flagged = true;
// TODO: email administrator
}