This commit is contained in:
yumoqing 2020-11-06 11:15:28 +08:00
parent 4d69db1822
commit 115608cf98
2 changed files with 10 additions and 11 deletions

View File

@ -36,19 +36,8 @@ class AuthAPI:
# setup aiohttp_auth.auth middleware in aiohttp fashion
auth.setup(app, policy)
app.middlewares.append(self.checkAuth)
# app.router.add_route('POST','/login',self.login)
app.router.add_route('GET', '/logout', self.logout)
async def login(self,request):
params = await request.post()
user_id = params.get('user',None)
password = params.get('password',None)
from_path = params.get('from_path',None)
if await self.checkUserPassword(user_id,password):
await auth.remember(request, user)
return web.HpptFound(from_path)
raise web.HTTPUnauthorized()
async def checkLogin(self,request):
"""
authorization header has the format:

View File

@ -20,6 +20,7 @@ from aiohttp.web_routedef import AbstractRouteDef
from appPublic.jsonConfig import getConfig
from appPublic.MiniI18N import getI18N
from appPublic.dictObject import DictObject, multiDict2Dict
from appPublic.timecost import TimeCost
from .baseProcessor import getProcessor
from .xlsxdsProcessor import XLSXDataSourceProcessor
@ -117,6 +118,15 @@ class ProcessorResource(StaticResource,Url2File):
return ns
async def _handle(self,request:Request) -> StreamResponse:
t = TimeCost()
name = str(request.url)
t.begin(name)
x = self._handle1(request)
t.end(name)
print(name,':', ':'.join(t.getTimeCost(name)))
return x
async def _handle1(self,request:Request) -> StreamResponse:
clientkeys = {
"iPhone":"iphone",
"iPad":"ipad",