Skip to content

Commit

Permalink
update log
Browse files Browse the repository at this point in the history
  • Loading branch information
odelcroi committed Dec 17, 2024
1 parent 5b6b2e3 commit a3cc2ee
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions synapse_sso_proconnect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,20 @@ async def on_user_login(
# This mapper is only invoked when the oidc user is not mapped to a MxId
# After the first login the oidc user unique field (sub) is mapped to a MxId
# Thus the 3PID substitution happens only at the first login of the oidc user

# Check if extra attributes were attached to user_id
sso_extra_attributes = self.module_api._auth_handler._extra_attributes.get(user_id, None)
logger.info("extra attributes found for user %s : %s",user_id, sso_extra_attributes or "nothing")
logger.info("extra attributes found for user %s : %s",user_id, sso_extra_attributes or "None")

if not sso_extra_attributes:
return

if sso_extra_attributes:
#check if extra attributes were attached to user_id
extra_attributes = sso_extra_attributes.extra_attributes
oidc_email = extra_attributes.get('oidc_email', None)
current_threepid_email = extra_attributes.get('current_threepid_email', None)
if(current_threepid_email and oidc_email and current_threepid_email != oidc_email):
# make the substitution
await self.substitute_threepid(user_id, current_threepid_email, oidc_email)
extra_attributes = sso_extra_attributes.extra_attributes
oidc_email = extra_attributes.get('oidc_email', None)
current_threepid_email = extra_attributes.get('current_threepid_email', None)
if(current_threepid_email and oidc_email and current_threepid_email != oidc_email):
# make the substitution
await self.substitute_threepid(user_id, current_threepid_email, oidc_email)

async def substitute_threepid(self,user_id, current_threepid_email, new_threepid_email) -> None:
"""
Expand Down

0 comments on commit a3cc2ee

Please sign in to comment.