feat(auth): add CustomOpenID class to force get_user_info implementation

This commit is contained in:
2025-10-11 21:37:49 +02:00
parent 7a67b12533
commit 0cf06b7bd9
4 changed files with 16 additions and 6 deletions

View File

@@ -10,9 +10,11 @@ from fastapi_users.authentication import (
)
from fastapi_users.authentication.strategy.jwt import JWTStrategy
from fastapi_users.db import SQLAlchemyUserDatabase
from httpx_oauth.oauth2 import BaseOAuth2
from app.models.user import User
from app.oauth.bank_id import BankID
from app.oauth.custom_openid import CustomOpenID
from app.oauth.moje_id import MojeIDOAuth
from app.services.db import get_user_db
from app.core.queue import enqueue_email
@@ -34,7 +36,7 @@ providers = {
}
def get_oauth_provider(name: str) -> Optional[MojeIDOAuth]:
def get_oauth_provider(name: str) -> Optional[BaseOAuth2]:
if name not in providers:
return None
return providers[name]
@@ -55,7 +57,7 @@ class UserManager(UUIDIDMixin, BaseUserManager[User, uuid.UUID]):
# set additional user info from the OAuth provider
provider = get_oauth_provider(oauth_name)
if provider is not None and hasattr(provider, "get_user_info"):
if provider is not None and isinstance(provider, CustomOpenID):
update_dict = await provider.get_user_info(access_token)
await self.user_db.update(user, update_dict)