@@ -7,7 +7,7 @@ export type tokenType = "local" | "jwtsignin" | "samltoken" | "tokenissued" | "w
77export type loginProvider = "saml" | "google" | "local" | "websocket" ;
88export type clientType = "browser" | "openrpa" | "nodered" | "webapp" | "openflow" | "powershell" | "mobileapp" | "samlverify" | "googleverify" | "aiotmobileapp" | "aiotwebapp" ;
99export class Audit {
10- public static LoginSuccess ( user : TokenUser , type : tokenType , provider : loginProvider , remoteip : string , clientagent : clientType , clientversion : string , parent : Span ) {
10+ public static async LoginSuccess ( user : TokenUser , type : tokenType , provider : loginProvider , remoteip : string , clientagent : clientType , clientversion : string , parent : Span ) : Promise < void > {
1111 const log : Singin = new Singin ( ) ;
1212 Base . addRight ( log , user . _id , user . name , [ Rights . read , Rights . update , Rights . invoke ] ) ;
1313 log . remoteip = remoteip ;
@@ -19,10 +19,9 @@ export class Audit {
1919 log . username = user . username ;
2020 log . clientagent = clientagent ;
2121 log . clientversion = clientversion ;
22- Config . db . InsertOne ( log , "audit" , 0 , false , Crypt . rootToken ( ) , parent )
23- . catch ( ( error ) => console . error ( "failed InsertOne in LoginSuccess: " + error ) ) ;
22+ await Config . db . InsertOne ( log , "audit" , 0 , false , Crypt . rootToken ( ) , parent ) ;
2423 }
25- public static ImpersonateSuccess ( user : TokenUser , impostor : TokenUser , clientagent : clientType , clientversion : string , parent : Span ) {
24+ public static async ImpersonateSuccess ( user : TokenUser , impostor : TokenUser , clientagent : clientType , clientversion : string , parent : Span ) : Promise < void > {
2625 const log : Singin = new Singin ( ) ;
2726 Base . addRight ( log , user . _id , user . name , [ Rights . read ] ) ;
2827 Base . addRight ( log , impostor . _id , impostor . name , [ Rights . read ] ) ;
@@ -36,10 +35,9 @@ export class Audit {
3635 log . impostorusername = impostor . username ;
3736 log . clientagent = clientagent ;
3837 log . clientversion = clientversion ;
39- Config . db . InsertOne ( log , "audit" , 0 , false , Crypt . rootToken ( ) , parent )
40- . catch ( ( error ) => console . error ( "failed InsertOne in ImpersonateSuccess: " + error ) ) ;
38+ Config . db . InsertOne ( log , "audit" , 0 , false , Crypt . rootToken ( ) , parent ) ;
4139 }
42- public static ImpersonateFailed ( user : TokenUser , impostor : TokenUser , clientagent : clientType , clientversion : string , parent : Span ) {
40+ public static async ImpersonateFailed ( user : TokenUser , impostor : TokenUser , clientagent : clientType , clientversion : string , parent : Span ) : Promise < void > {
4341 const log : Singin = new Singin ( ) ;
4442 Base . addRight ( log , user . _id , user . name , [ Rights . read ] ) ;
4543 Base . addRight ( log , impostor . _id , impostor . name , [ Rights . read ] ) ;
@@ -52,10 +50,9 @@ export class Audit {
5250 log . impostorname = impostor . name ;
5351 log . clientagent = clientagent ;
5452 log . clientversion = clientversion ;
55- Config . db . InsertOne ( log , "audit" , 0 , false , Crypt . rootToken ( ) , parent )
56- . catch ( ( error ) => console . error ( "failed InsertOne in ImpersonateFailed: " + error ) ) ;
53+ Config . db . InsertOne ( log , "audit" , 0 , false , Crypt . rootToken ( ) , parent ) ;
5754 }
58- public static LoginFailed ( username : string , type : tokenType , provider : loginProvider , remoteip : string , clientagent : clientType , clientversion : string , parent : Span ) {
55+ public static async LoginFailed ( username : string , type : tokenType , provider : loginProvider , remoteip : string , clientagent : clientType , clientversion : string , parent : Span ) : Promise < void > {
5956 const log : Singin = new Singin ( ) ;
6057 log . remoteip = remoteip ;
6158 log . success = false ;
@@ -64,10 +61,9 @@ export class Audit {
6461 log . username = username ;
6562 log . clientagent = clientagent ;
6663 log . clientversion = clientversion ;
67- Config . db . InsertOne ( log , "audit" , 0 , false , Crypt . rootToken ( ) , parent )
68- . catch ( ( error ) => console . error ( "failed InsertOne in LoginFailed: " + error ) ) ;
64+ Config . db . InsertOne ( log , "audit" , 0 , false , Crypt . rootToken ( ) , parent ) ;
6965 }
70- public static NoderedAction ( user : TokenUser , success : boolean , name : string , type : string , image : string , instancename : string , parent : Span ) {
66+ public static async NoderedAction ( user : TokenUser , success : boolean , name : string , type : string , image : string , instancename : string , parent : Span ) : Promise < void > {
7167 const log : Nodered = new Nodered ( ) ;
7268 Base . addRight ( log , user . _id , user . name , [ Rights . read ] ) ;
7369 log . success = success ;
@@ -85,8 +81,7 @@ export class Audit {
8581
8682 }
8783 if ( ! NoderedUtil . IsNullEmpty ( instancename ) ) log . name = instancename ;
88- Config . db . InsertOne ( log , "audit" , 0 , false , Crypt . rootToken ( ) , parent )
89- . catch ( ( error ) => console . error ( "failed InsertOne in LoginFailed: " + error ) ) ;
84+ await Config . db . InsertOne ( log , "audit" , 0 , false , Crypt . rootToken ( ) , parent ) ;
9085 }
9186}
9287export class Singin extends Base {
0 commit comments