mirror of
https://github.com/fastapi-practices/fastapi_best_architecture.git
synced 2025-08-20 16:40:10 +08:00
update DependsSession to CurrentSession
This commit is contained in:
@ -13,7 +13,7 @@ from typing_extensions import Annotated
|
|||||||
from backend.app.common.exception.errors import AuthorizationError, TokenError
|
from backend.app.common.exception.errors import AuthorizationError, TokenError
|
||||||
from backend.app.core.conf import settings
|
from backend.app.core.conf import settings
|
||||||
from backend.app.crud.crud_user import UserDao
|
from backend.app.crud.crud_user import UserDao
|
||||||
from backend.app.database.db_mysql import DependsSession
|
from backend.app.database.db_mysql import CurrentSession
|
||||||
from backend.app.models import User
|
from backend.app.models import User
|
||||||
|
|
||||||
pwd_context = CryptContext(schemes=['bcrypt'], deprecated='auto')
|
pwd_context = CryptContext(schemes=['bcrypt'], deprecated='auto')
|
||||||
@ -59,7 +59,7 @@ def create_access_token(data: Union[int, Any], expires_delta: Union[timedelta, N
|
|||||||
return encoded_jwt
|
return encoded_jwt
|
||||||
|
|
||||||
|
|
||||||
async def get_current_user(db: DependsSession, token: str = Depends(oauth2_schema)) -> User:
|
async def get_current_user(db: CurrentSession, token: str = Depends(oauth2_schema)) -> User:
|
||||||
"""
|
"""
|
||||||
Get the current user through tokens
|
Get the current user through tokens
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ async def get_db() -> AsyncSession:
|
|||||||
|
|
||||||
|
|
||||||
# Session 依赖注入
|
# Session 依赖注入
|
||||||
DependsSession = Annotated[AsyncSession, Depends(get_db)]
|
CurrentSession = Annotated[AsyncSession, Depends(get_db)]
|
||||||
|
|
||||||
|
|
||||||
async def create_table():
|
async def create_table():
|
||||||
|
Reference in New Issue
Block a user