pzx-web-api/app/api/v1/auth.py

25 lines
634 B
Python
Raw Normal View History

2023-08-11 16:36:56 +08:00
from apiflask import APIBlueprint
from app import rpc
from app.api.v1.schema.auth import WechatLoginIn, WechatLoginOut, RefreshTokenIn, RefreshTokenOut
auth = APIBlueprint('auth', __name__)
@auth.post('/wechat_login')
@auth.input(WechatLoginIn)
@auth.output(WechatLoginOut)
def wechat_login(data):
2023-08-11 16:52:34 +08:00
try:
result = rpc.admin.wechat_login(data['code'])
except Exception as e:
raise e
2023-08-11 16:36:56 +08:00
return result
@auth.get('/refresh_token')
@auth.input(RefreshTokenIn, location='query')
@auth.output(RefreshTokenOut)
def refresh_token(data):
result = rpc.admin.refresh_token(data['refresh_token'])
return result