mirror of
https://github.com/fastapi-admin/fastapi-admin.git
synced 2026-03-13 10:32:25 +08:00
Make get_current_admin error to 401 and add 401 error page.
This commit is contained in:
@@ -3,7 +3,7 @@ from typing import List, Optional, Type
|
||||
from fastapi import Depends, HTTPException
|
||||
from fastapi.params import Path
|
||||
from starlette.requests import Request
|
||||
from starlette.status import HTTP_404_NOT_FOUND
|
||||
from starlette.status import HTTP_401_UNAUTHORIZED, HTTP_404_NOT_FOUND
|
||||
from tortoise import Tortoise
|
||||
|
||||
from fastapi_admin.exceptions import InvalidResource
|
||||
@@ -68,5 +68,5 @@ def get_redis(request: Request):
|
||||
def get_current_admin(request: Request):
|
||||
admin = request.state.admin
|
||||
if not admin:
|
||||
raise HTTPException(status_code=HTTP_404_NOT_FOUND)
|
||||
raise HTTPException(status_code=HTTP_401_UNAUTHORIZED)
|
||||
return admin
|
||||
|
||||
Reference in New Issue
Block a user