| | |
| | | else: |
| | | return {} |
| | | |
| | | async def register(self, username: str, password: str): |
| | | async def register(self, username: str, password: str, token:str=""): |
| | | public_key = await self.get_public_key_api() |
| | | password = BishengCrypto(public_key, settings.PRIVATE_KEY).encrypt(password) |
| | | async with httpx.AsyncClient() as client: |
| | |
| | | json={"user_name": username, "password": password}, |
| | | headers={'Content-Type': 'application/json'} |
| | | ) |
| | | return self._check_response(response) |
| | | res = self._check_response(response) |
| | | if isinstance(res, dict): |
| | | res["id"] = res.get("user_id") |
| | | return res |
| | | |
| | | async def login(self, username: str, password: str) -> str: |
| | | public_key = await self.get_public_key_api() |