This commit is contained in:
yumoqing 2025-05-06 18:04:16 +08:00
parent 5dfdb4494e
commit 3f5b71457d
2 changed files with 12 additions and 5 deletions

View File

@ -1,6 +1,7 @@
from functools import partial from functools import partial
from sqlor.dbpools import DBPools from sqlor.dbpools import DBPools
from appPublic.httpclient import JsonHttpAPI from appPublic.httpclient import JsonHttpAPI
from appPublic.log import debug, exception,
from ahserver.globalEnv import password_decode from ahserver.globalEnv import password_decode
from aiohttp import web from aiohttp import web
@ -50,17 +51,21 @@ where
if rec.need_auth and self.auth_api is None: if rec.need_auth and self.auth_api is None:
self.auth_api = await self.get_authapi(sor) self.auth_api = await self.get_authapi(sor)
if rec.need_auth and self.auth_api is None: if rec.need_auth and self.auth_api is None:
raise Exception(f'{rec.appname} app has not auth api but need') e = Exception(f'{rec.appname} app has not auth api but need')
exception(f'{e=}, {format_exc()}')
raise e
rec.auth_api = self.auth_api rec.auth_api = self.auth_api
rec.apikey_orgid = orgid rec.apikey_orgid = orgid
return recs[0] return recs[0]
return None return None
def request(self, apiname, ns): async def request(self, apiname, ns):
orgs = ns.get('orgs') orgs = ns.get('orgs')
api = await self.get_apiinfo(orgs, apiname) api = await self.get_apiinfo(orgs, apiname)
if api is None: if api is None:
raise Exception(f'{self.appid} app has not {apiname} api') e = Exception(f'{self.appid} app has not {apiname} api')
exception(f'{e=}, {format_exc()}')
raise e
ns1 = self.env.copy() ns1 = self.env.copy()
ns1['apikey'] = api.apikey ns1['apikey'] = api.apikey
ns1['secretkey'] = api.secretkey ns1['secretkey'] = api.secretkey
@ -76,7 +81,9 @@ where
datatmpl=self.auth_api.data, datatmpl=self.auth_api.data,
resptmpl=self.auth_api.response) resptmpl=self.auth_api.response)
if self.auth_ret is None: if self.auth_ret is None:
raise Exception(f'{self.appid} app auth error') e = Exception(f'{self.appid} app auth error')
exception(f'{e=}, {format_exc()}')
raise e
ns1.update(self.auth_ret) ns1.update(self.auth_ret)
stream_func = None stream_func = None
if api.stream: if api.stream:

View File

@ -1,4 +1,4 @@
from ahserver.serverenv import get_serverenv from ahserver.serverenv import ServerEnv
from .appapi import AppAPI, AiohttpAppAPI from .appapi import AppAPI, AiohttpAppAPI
def load_uapi(): def load_uapi():