@@ -68,12 +68,11 @@ def init(self, config_path):
6868 self .configs .get_one ("token" ),
6969 self .configs .get_one ("main_endpoint" ),
7070 )
71- if token :
72- token = token .value
73- if main_endpoint :
74- main_endpoint = main_endpoint .value
71+ token = None if not token else token .value
72+ main_endpoint = None if not main_endpoint else main_endpoint .value
7573 if not main_endpoint :
7674 self .configs .insert (ConfigEntity ("main_endpoint" , constances .BACKEND_URL ))
75+ main_endpoint = constances .BACKEND_URL
7776 if not token :
7877 self .configs .insert (ConfigEntity ("token" , "" ))
7978 self ._logger .warning ("Fill config.json" )
@@ -94,9 +93,18 @@ def init(self, config_path):
9493 self ._backend_client .api_url = main_endpoint
9594 self ._backend_client ._auth_token = token
9695 self ._backend_client .get_session .cache_clear ()
97- self ._team_id = int (self .configs .get_one ("token" ).value .split ("=" )[- 1 ])
96+ token = self .configs .get_one ("token" ).value
97+ self .validate_token (token )
98+ self ._team_id = int (token .split ("=" )[- 1 ])
9899 self ._team = None
99100
101+ @staticmethod
102+ def validate_token (token : str ):
103+ try :
104+ return int (token .split ("=" )[- 1 ])
105+ except Exception :
106+ raise AppException ("Invalid token." )
107+
100108 @property
101109 def config_path (self ):
102110 return self ._config_path
0 commit comments