Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
return str
Browse files Browse the repository at this point in the history
  • Loading branch information
OmmyZhang committed Sep 23, 2020
1 parent 8f05f01 commit 2f4b335
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions synapse/handlers/oidc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,27 +907,23 @@ async def _map_userinfo_to_user(

localpart = map_username_to_mxid_localpart(attributes["localpart"])

user_id = UserID(localpart, self._hostname)
users = await self._datastore.get_users_by_id_case_insensitive(
user_id.to_string()
)
user_id = UserID(localpart, self._hostname).to_string()
users = await self._datastore.get_users_by_id_case_insensitive(user_id)
if users:
if self._allow_existing_users:
if len(users) == 1:
registered_user_id = UserID.from_string(next(iter(users)))
registered_user_id = next(iter(users))
elif user_id in users:
registered_user_id = user_id
else:
raise MappingException(
"Attempted to login as '{}' but it matches more than one user inexactly: {}".format(
user_id.to_string(), list(users.keys())
user_id, list(users.keys())
)
)
else:
# This mxid is taken
raise MappingException(
"mxid '{}' is already taken".format(user_id.to_string())
)
raise MappingException("mxid '{}' is already taken".format(user_id))
else:
# It's the first time this user is logging in and the mapped mxid was
# not taken, register the user
Expand Down

0 comments on commit 2f4b335

Please sign in to comment.