Commit d3b3699e authored by lcn's avatar lcn

调整为公共登录

parent 04552a63
...@@ -119,11 +119,12 @@ async def auth_verify(request): ...@@ -119,11 +119,12 @@ async def auth_verify(request):
# 直接将请求转发到auth # 直接将请求转发到auth
resp_str, status = await AioHttpUtils().post( resp_str, status = await AioHttpUtils().post(
SETTING.verify_url, SETTING.verify_url,
data={}, data={"db": SETTING.mysql_db},
timeout=50, timeout=50,
headers={"Authorization": f"Bearer {token}"} headers={"Authorization": f"Bearer {token}"}
) )
log.info(f"request auth_url resp_str={resp_str} {type(resp_str)} status={status}") log.info(
f"request auth_url resp_str={resp_str} {type(resp_str)} status={status}")
if status == 200: if status == 200:
payload = ujson.loads(resp_str) payload = ujson.loads(resp_str)
setattr(request.ctx, "user_id", payload["user_id"]) setattr(request.ctx, "user_id", payload["user_id"])
......
...@@ -20,7 +20,8 @@ async def wechat_login(args, host): ...@@ -20,7 +20,8 @@ async def wechat_login(args, host):
"user_info": args.get("user_info"), "user_info": args.get("user_info"),
"client_name": args.get("client_name"), "client_name": args.get("client_name"),
"host": host, "host": host,
"product": args.get("product") "product": args.get("product"),
"db": SETTING.mysql_db
} }
try: try:
...@@ -45,7 +46,8 @@ async def app_login(args, host): ...@@ -45,7 +46,8 @@ async def app_login(args, host):
"client_name": args.get("client_name"), "client_name": args.get("client_name"),
"unionid": args.get("unionid"), "unionid": args.get("unionid"),
"host": host, "host": host,
"product": args.get("product") "product": args.get("product"),
"db": SETTING.mysql_db
} }
if not args.get("unionid"): if not args.get("unionid"):
return 401, {"code": 40001, "data": None, "message": "unionid is None"} return 401, {"code": 40001, "data": None, "message": "unionid is None"}
...@@ -72,6 +74,7 @@ async def web_login(args, host): ...@@ -72,6 +74,7 @@ async def web_login(args, host):
"code": args['code'], "code": args['code'],
"client_name": args.get("client_name"), "client_name": args.get("client_name"),
"host": host, "host": host,
"db": SETTING.mysql_db
} }
try: try:
# auth_url = "http://0.0.0.0:9000/unify-api/auth" # auth_url = "http://0.0.0.0:9000/unify-api/auth"
...@@ -110,7 +113,8 @@ async def third_login(args, host): ...@@ -110,7 +113,8 @@ async def third_login(args, host):
"password": password, "password": password,
"client_name": args.get("client_name"), "client_name": args.get("client_name"),
"host": host, "host": host,
"product": args.get("product") "product": args.get("product"),
"db": SETTING.mysql_db
} }
try: try:
log.info( log.info(
...@@ -148,6 +152,7 @@ async def web_third_login(args, host): ...@@ -148,6 +152,7 @@ async def web_third_login(args, host):
"password": password, "password": password,
"client_name": args.get("client_name"), "client_name": args.get("client_name"),
"host": host, "host": host,
"db": SETTING.mysql_db
} }
try: try:
log.info( log.info(
...@@ -197,6 +202,7 @@ async def validation_login(args, host): ...@@ -197,6 +202,7 @@ async def validation_login(args, host):
"user_id": user["user_id"], "user_id": user["user_id"],
"client_name": client_name, "client_name": client_name,
"host": host, "host": host,
"db": SETTING.mysql_db
} }
try: try:
log.info(SETTING.auth_url, f"request auth_url={SETTING.auth_url} " log.info(SETTING.auth_url, f"request auth_url={SETTING.auth_url} "
......
...@@ -28,7 +28,7 @@ class AuthView(HTTPMethodView): ...@@ -28,7 +28,7 @@ class AuthView(HTTPMethodView):
resp_str, status_code = await AioHttpUtils().post( resp_str, status_code = await AioHttpUtils().post(
SETTING.auth_url, SETTING.auth_url,
{"user_name": "balabala", "password": "balabala", {"user_name": "balabala", "password": "balabala",
"client_name": client_name}, "client_name": client_name, "db": SETTING.mysql_db},
timeout=50, timeout=50,
) )
print(f"resp_str = {resp_str} status={status_code}") print(f"resp_str = {resp_str} status={status_code}")
......
...@@ -152,7 +152,8 @@ async def post_save_userinfo(request, body: SaveUserReq): ...@@ -152,7 +152,8 @@ async def post_save_userinfo(request, body: SaveUserReq):
"phone": phone, "phone": phone,
"client_name": "validation", "client_name": "validation",
"host": request.host, "host": request.host,
"user_id": user["user_id"] "user_id": user["user_id"],
"db": SETTING.mysql_db
} }
resp_str, status = await AioHttpUtils().post( resp_str, status = await AioHttpUtils().post(
SETTING.auth_url, SETTING.auth_url,
......
...@@ -54,8 +54,13 @@ async def get_user_logout(request) -> Success: ...@@ -54,8 +54,13 @@ async def get_user_logout(request) -> Success:
# await jwt_utils.store_token_blacklist(token) # await jwt_utils.store_token_blacklist(token)
try: try:
log.info(f"request logout_url={SETTING.logout_url}") log.info(f"request logout_url={SETTING.logout_url}")
resp_str, status = await AioHttpUtils().get( request_body = {
"db": SETTING.mysql_db
}
resp_str, status = await AioHttpUtils().post(
SETTING.logout_url, SETTING.logout_url,
request_body,
timeout=50,
headers={"Authorization": f"Bearer {token}"}, headers={"Authorization": f"Bearer {token}"},
) )
log.info(f"request auth_url resp_str={resp_str} status={status}") log.info(f"request auth_url resp_str={resp_str} status={status}")
......
...@@ -21,7 +21,11 @@ class RefreshView(HTTPMethodView): ...@@ -21,7 +21,11 @@ class RefreshView(HTTPMethodView):
status=200) status=200)
resp, status_code = await AioHttpUtils().post( resp, status_code = await AioHttpUtils().post(
SETTING.refresh_token_url, SETTING.refresh_token_url,
{"refresh_token": refresh_token, "client_name": client_name}, {
"refresh_token": refresh_token,
"client_name": client_name,
"db": SETTING.mysql_db
},
timeout=50, timeout=50,
headers={"Authorization": f"Bearer {token}"} headers={"Authorization": f"Bearer {token}"}
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment