update DependsSession to CurrentSession

This commit is contained in:
wu
2023-04-14 00:23:26 +08:00
committed by Wu Clan
parent b335fc1be7
commit 9481500b27
2 changed files with 3 additions and 3 deletions

View File

@ -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

View File

@ -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():