mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-08-15 11:11:16 +08:00
Native model and generic ID (#971)
* Use a generic Protocol model for User instead of Pydantic
* Remove UserDB Pydantic schema
* Harmonize schema variable naming to avoid confusions
* Revamp OAuth account model management
* Revamp AccessToken DB strategy to adopt generic model approach
* Make ID a generic instead of forcing UUIDs
* Improve generic typing
* Improve Strategy typing
* Tweak base DB typing
* Don't set Pydantic schemas on FastAPIUsers class: pass it directly on router creation
* Add IntegerIdMixin and export related classes
* Start to revamp doc for V10
* Revamp OAuth documentation
* Fix code highlights
* Write the 9.x.x ➡️ 10.x.x migration doc
* Fix pyproject.toml
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, models.ID]],
|
||||
):
|
||||
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, models.ID],
|
||||
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, models.ID],
|
||||
user: models.UP,
|
||||
token: str,
|
||||
response: Response,
|
||||
) -> Any:
|
||||
|
Reference in New Issue
Block a user