69 lines
2.4 KiB
Python
69 lines
2.4 KiB
Python
"""认证模块
|
|
|
|
对应前端源码:
|
|
api/core/auth.ts - 登录/登出/SSO
|
|
api/core/user.ts - 用户信息/扫码登录
|
|
"""
|
|
|
|
from typing import Optional
|
|
from aibridge.client import JNPFClient
|
|
from aibridge.models import APIResponse
|
|
|
|
|
|
class AuthAPI:
|
|
"""认证 API"""
|
|
|
|
def __init__(self, client: JNPFClient):
|
|
self._client = client
|
|
|
|
def login(self, account: str, password: str) -> APIResponse:
|
|
"""登录(自动处理密码加密)"""
|
|
return self._client.login(account, password)
|
|
|
|
def logout(self) -> APIResponse:
|
|
"""退出登录"""
|
|
return self._client.logout()
|
|
|
|
def get_user_info(self, system_code: str = "",
|
|
is_backend: int = 0) -> APIResponse:
|
|
"""获取当前用户信息"""
|
|
return self._client.get_user_info(system_code, is_backend)
|
|
|
|
def get_login_config(self) -> APIResponse:
|
|
"""获取登录配置"""
|
|
return self._client.get_login_config()
|
|
|
|
def get_config(self, account: str) -> APIResponse:
|
|
"""获取系统默认配置"""
|
|
return self._client.request("GET", f"/api/oauth/getConfig/{account}")
|
|
|
|
def get_ticket(self) -> APIResponse:
|
|
"""获取登录票据"""
|
|
return self._client.request("GET", "/api/oauth/getTicket")
|
|
|
|
def get_ticket_status(self, ticket: str) -> APIResponse:
|
|
"""根据票据获取登录状态"""
|
|
return self._client.request("GET", f"/api/oauth/getTicketStatus/{ticket}")
|
|
|
|
def unlock(self, data: dict) -> APIResponse:
|
|
"""锁屏解锁"""
|
|
return self._client.request("POST", "/api/oauth/LockScreen", data=data)
|
|
|
|
def socials_login(self, params: dict) -> APIResponse:
|
|
"""第三方登录回调"""
|
|
return self._client.request("POST", "/api/oauth/Login/socials",
|
|
params=params,
|
|
_form_urlencoded=True)
|
|
|
|
def get_code_certificate(self) -> APIResponse:
|
|
"""扫码登录获取凭证"""
|
|
return self._client.request("GET", "/api/oauth/codeCertificate")
|
|
|
|
def get_code_certificate_status(self, ticket: str) -> APIResponse:
|
|
"""扫码登录获取凭证状态"""
|
|
return self._client.request("GET", f"/api/oauth/codeCertificateStatus/{ticket}")
|
|
|
|
def update_password_message(self) -> APIResponse:
|
|
"""修改密码信息发送"""
|
|
return self._client.request("POST", "/api/oauth/updatePasswordMessage")
|