mirror of
https://github.com/fastapi-practices/fastapi_best_architecture.git
synced 2025-08-18 23:11:48 +08:00
Add RBAC authorisation and some tools or optimisations (#41)
* WIP: add rbac authorization * Perform pre-commit fixes * add rbac route whitelist * add init test data user role associations * Restore database table id naming to fix generic crud base * Add database section value uniqueness settings * Update the test directory to tests * Update route_name file name to health_check * Split user auth and user action interfaces * Fix conflict between merge and current branch * Add pymysql dependencies * Fix RBAC authentication method * Add the select serialisation tool * Fix missing return messages due to global exception handler slicing * Update the user interface with associated relationships * Add items to be completed * Perform pre-commit fixes * Add pre-made routers * Paging data return structure optimisation * Split user auth and user interface tests * Fix user register test data structure error * Fix duplicate named test classes
This commit is contained in:
@ -77,7 +77,7 @@ def register_exception(app: FastAPI):
|
||||
message += (
|
||||
f'{data.get(field, field)} {_msg}' + ', '
|
||||
if errors_len > 0
|
||||
else f'{data.get(field, field)} {_msg}'
|
||||
else f'{data.get(field, field)} {_msg}' + '.'
|
||||
)
|
||||
elif isinstance(raw_error.exc, json.JSONDecodeError):
|
||||
message += 'json解析失败'
|
||||
@ -85,7 +85,7 @@ def register_exception(app: FastAPI):
|
||||
status_code=422,
|
||||
content=response_base.fail(
|
||||
code=422,
|
||||
msg='请求参数非法' if len(message) == 0 else f'请求参数非法: {message[:-1]}',
|
||||
msg='请求参数非法' if len(message) == 0 else f'请求参数非法: {message}',
|
||||
data={'errors': exc.errors()} if message == '' and settings.UVICORN_RELOAD is True else None,
|
||||
),
|
||||
)
|
||||
|
Reference in New Issue
Block a user