mirror of
https://github.com/fastapi-admin/fastapi-admin.git
synced 2025-08-14 18:58:13 +08:00
Make get_current_admin
error to 401
and add 401
error page.
This commit is contained in:
@ -6,7 +6,12 @@ from fastapi import FastAPI
|
||||
from starlette.middleware.cors import CORSMiddleware
|
||||
from starlette.responses import RedirectResponse
|
||||
from starlette.staticfiles import StaticFiles
|
||||
from starlette.status import HTTP_403_FORBIDDEN, HTTP_404_NOT_FOUND, HTTP_500_INTERNAL_SERVER_ERROR
|
||||
from starlette.status import (
|
||||
HTTP_401_UNAUTHORIZED,
|
||||
HTTP_403_FORBIDDEN,
|
||||
HTTP_404_NOT_FOUND,
|
||||
HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
)
|
||||
from tortoise.contrib.fastapi import register_tortoise
|
||||
|
||||
from examples import settings
|
||||
@ -18,6 +23,7 @@ from fastapi_admin.exceptions import (
|
||||
forbidden_error_exception,
|
||||
not_found_error_exception,
|
||||
server_error_exception,
|
||||
unauthorized_error_exception,
|
||||
)
|
||||
|
||||
|
||||
@ -36,6 +42,7 @@ def create_app():
|
||||
admin_app.add_exception_handler(HTTP_500_INTERNAL_SERVER_ERROR, server_error_exception)
|
||||
admin_app.add_exception_handler(HTTP_404_NOT_FOUND, not_found_error_exception)
|
||||
admin_app.add_exception_handler(HTTP_403_FORBIDDEN, forbidden_error_exception)
|
||||
admin_app.add_exception_handler(HTTP_401_UNAUTHORIZED, unauthorized_error_exception)
|
||||
|
||||
@app.on_event("startup")
|
||||
async def startup():
|
||||
|
Reference in New Issue
Block a user