mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-08-16 20:11:20 +08:00
Use a generic Protocol model for User instead of Pydantic
This commit is contained in:
@ -14,7 +14,7 @@ from fastapi_users.authentication.transport import (
|
||||
from fastapi_users.types import DependencyCallable
|
||||
|
||||
|
||||
class AuthenticationBackend(Generic[models.UC, models.UD]):
|
||||
class AuthenticationBackend(Generic[models.UP]):
|
||||
"""
|
||||
Combination of an authentication transport and strategy.
|
||||
|
||||
@ -33,7 +33,7 @@ class AuthenticationBackend(Generic[models.UC, models.UD]):
|
||||
self,
|
||||
name: str,
|
||||
transport: Transport,
|
||||
get_strategy: DependencyCallable[Strategy[models.UC, models.UD]],
|
||||
get_strategy: DependencyCallable[Strategy[models.UP]],
|
||||
):
|
||||
self.name = name
|
||||
self.transport = transport
|
||||
@ -41,8 +41,8 @@ class AuthenticationBackend(Generic[models.UC, models.UD]):
|
||||
|
||||
async def login(
|
||||
self,
|
||||
strategy: Strategy[models.UC, models.UD],
|
||||
user: models.UD,
|
||||
strategy: Strategy[models.UP],
|
||||
user: models.UP,
|
||||
response: Response,
|
||||
) -> Any:
|
||||
token = await strategy.write_token(user)
|
||||
@ -50,8 +50,8 @@ class AuthenticationBackend(Generic[models.UC, models.UD]):
|
||||
|
||||
async def logout(
|
||||
self,
|
||||
strategy: Strategy[models.UC, models.UD],
|
||||
user: models.UD,
|
||||
strategy: Strategy[models.UP],
|
||||
user: models.UP,
|
||||
token: str,
|
||||
response: Response,
|
||||
) -> Any:
|
||||
|
Reference in New Issue
Block a user