Skip to content

Commit

Permalink
fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
odelcroi committed Dec 9, 2024
1 parent 64c1170 commit 5b8ea4a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions synapse_sso_proconnect/proconnect_mapping.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import string

import attr
from authlib.oidc.core import UserInfo
from typing import Any, Dict, List, Optional, Tuple
from authlib.oidc.core import UserInfo # type: ignore
from typing import Any, Dict, List

from synapse.handlers.oidc import OidcMappingProvider, Token, UserAttributeDict
from synapse.handlers.sso import MappingException
Expand All @@ -27,7 +27,9 @@ def parse_config(config: Dict[str, Any]) -> ProConnectMappingConfig:
return ProConnectMappingConfig(**config)

def get_remote_user_id(self, userinfo: UserInfo) -> str:
return userinfo.sub
if not hasattr(userinfo, 'sub') or not userinfo.sub:
raise MappingException("The 'sub' attribute is missing or empty in the provided UserInfo object.")
return str(userinfo.sub)

async def map_user_attributes(
self, userinfo: UserInfo, token: Token, failures: int
Expand Down Expand Up @@ -71,15 +73,16 @@ async def map_user_attributes(
{},
)

return UserAttributeDict(
return UserAttributeDict( # type: ignore
localpart=localpart,
emails=[userinfo.email],
confirm_localpart=False,
display_name=display_name,
)

# Search user ID by its email, retrying with replacements if necessary.
async def search_user_id_by_threepid(self, email: str):
async def search_user_id_by_threepid(self, email: str
)-> str | None:
# Try to find the user ID using the provided email
userId = await self.module_api._store.get_user_id_by_threepid("email", email)

Expand Down

0 comments on commit 5b8ea4a

Please sign in to comment.