Skip to content

Commit b8e422f

Browse files
authored
Merge pull request #50 from samson0v/master
Added public_login method
2 parents a5a9b04 + ce7d735 commit b8e422f

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

tb_rest_client/rest_client_base.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,26 @@ def login(self, username, password):
112112

113113
token_json = post(self.base_url + "/api/auth/login", json={"username": username, "password": password},
114114
verify=self.configuration.verify_ssl).json()
115+
self.__save_token(token_json)
116+
117+
self.__load_configuration()
118+
119+
def public_login(self, public_id):
120+
token_json = post(self.base_url + "/api/auth/login/public", json={"publicId": public_id},
121+
verify=self.configuration.verify_ssl).json()
122+
123+
self.__save_token(token_json)
124+
self.__load_configuration()
125+
126+
def __save_token(self, token_json):
115127
token = None
116128
if isinstance(token_json, dict) and token_json.get("token") is not None:
117129
token = token_json["token"]
118130
self.configuration.api_key_prefix["X-Authorization"] = "Bearer"
119131
self.configuration.api_key["X-Authorization"] = token
120132
self.token_info['token'] = token
121133

134+
def __load_configuration(self):
122135
self.api_client = ApiClient(self.configuration)
123136
self.__load_controllers()
124137

tb_rest_client/rest_client_pe.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ def login(self, username, password):
2929
super(RestClientPE, self).login(username=username, password=password)
3030
self.__load_controllers()
3131

32+
def public_login(self, public_id):
33+
super(RestClientPE, self).public_login(public_id=public_id)
34+
self.__load_controllers()
35+
3236
# Self Registration Controller
3337
def get_privacy_policy(self, ):
3438
return self.self_registration_controller.get_privacy_policy_using_get()

0 commit comments

Comments
 (0)