@@ -9,18 +9,29 @@ pub struct TokenValidationEvent {
99}
1010
1111impl TokenValidationEvent {
12- pub fn internal ( token_id : String , is_successful : bool , details : HashSet < String > ) -> Self {
12+ pub fn internal ( token : & str , is_successful : bool , details : HashSet < String > ) -> Self {
13+ let token_hash = md5:: compute ( token) ;
1314 Self {
14- token_id,
15+ token_id : format ! ( "md5:{:x}" , token_hash ) ,
1516 result : make_result ( is_successful) ,
1617 reason_errors : details,
1718 token_type : "internal" . to_string ( ) ,
1819 }
1920 }
2021
21- pub fn external ( token_id : String , is_successful : bool , details : HashSet < String > ) -> Self {
22+ pub fn external ( token : & str , is_successful : bool , details : HashSet < String > ) -> Self {
23+ let token_hash = md5:: compute ( token) ;
2224 Self {
23- token_id,
25+ token_id : format ! ( "md5:{:x}" , token_hash) ,
26+ result : make_result ( is_successful) ,
27+ reason_errors : details,
28+ token_type : "external" . to_string ( ) ,
29+ }
30+ }
31+
32+ pub fn external_empty ( is_successful : bool , details : HashSet < String > ) -> Self {
33+ Self {
34+ token_id : "token-not-provided" . to_string ( ) ,
2435 result : make_result ( is_successful) ,
2536 reason_errors : details,
2637 token_type : "external" . to_string ( ) ,
0 commit comments