mirror of
https://github.com/dat515-2025/Group-8.git
synced 2026-03-22 15:12:08 +01:00
feat(auth): add CustomOpenID class to force get_user_info implementation
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user