32 lines
795 B
Python
32 lines
795 B
Python
"""
|
|
认证 API 客户端
|
|
"""
|
|
|
|
from httpx import AsyncClient
|
|
|
|
|
|
class AuthAPI:
|
|
"""认证 API 客户端"""
|
|
|
|
def __init__(self, client: AsyncClient):
|
|
self.client = client
|
|
|
|
async def login(self, username: str, password: str):
|
|
"""登录"""
|
|
return await self.client.post('/api/auth/login', json={
|
|
'username': username,
|
|
'password': password
|
|
})
|
|
|
|
async def register(self, username: str, password: str, email: str):
|
|
"""注册"""
|
|
return await self.client.post('/api/auth/register', json={
|
|
'username': username,
|
|
'password': password,
|
|
'email': email
|
|
})
|
|
|
|
async def logout(self):
|
|
"""登出"""
|
|
return await self.client.post('/api/auth/logout')
|