修复空间权限

This commit is contained in:
wuaho 2021-10-09 16:11:19 +08:00
parent 57bb539d4d
commit 4bc131a82c
2 changed files with 4 additions and 3 deletions

View File

@ -264,7 +264,8 @@ async def read_kanban(
'children': [],
'_id': item['_id']
})
res['spaces'][-1]['authority'] = 'rw' if current_user.id in item['members'] else 'r'
authority = {item['user_id']: item['authority'] for item in item['members']}
res['spaces'][-1]['authority'] = authority.get(current_user.id, 'r')
for f in await crud.folder.find_many(db, {'pid': item['_id']}):
res['spaces'][-1]['children'].append({

View File

@ -87,12 +87,12 @@ app.add_middleware(
@app.exception_handler(RequestValidationError)
async def validation_exception_handler(request, exc):
return Response(schemas.Msg(code='-4', msg='请求错误', data=str(exc)).json(), status_code=400)
return Response(schemas.Msg(code=-4, msg='请求错误', data=str(exc)).json(), status_code=400)
@app.exception_handler(Exception)
async def http_exception_handler(request, exc):
return Response(schemas.Msg(code='-3', msg='服务器错误').json(), status_code=500)
return Response(schemas.Msg(code=-3, msg='服务器错误').json(), status_code=500)
@app.middleware("http")