forked from openiap/opencore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAudit.ts
More file actions
38 lines (37 loc) · 1.2 KB
/
Copy pathAudit.ts
File metadata and controls
38 lines (37 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { Base } from "./base";
import { Config } from "./Config";
import { TokenUser } from "./TokenUser";
export class Audit {
public static LoginSuccess(user: TokenUser, type: string, provider: string, remoteip: string) {
var log: Singin = new Singin();
log.remoteip = remoteip;
log.success = true;
log.type = type;
log.provider = provider;
log.userid = user._id;
log.name = user.name;
log.username = user.username;
Config.db.InsertOne(log, "audit", 0, false, TokenUser.rootToken());
}
public static LoginFailed(username: string, type: string, provider: string, remoteip: string) {
var log: Singin = new Singin();
log.remoteip = remoteip;
log.success = false;
log.type = type;
log.provider = provider;
log.username = username;
Config.db.InsertOne(log, "audit", 0, false, TokenUser.rootToken());
}
}
export class Singin extends Base {
public success: boolean;
public type: string;
public provider: string;
public userid: string;
public username: string;
public remoteip: string;
constructor() {
super();
this._type = "signin";
}
}