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

Commit

Permalink
Update asserts and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Apr 23, 2021
1 parent e575c27 commit 1f72738
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion synapse/handlers/oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,10 @@ async def grandfather_existing_users() -> Optional[str]:
# and attempt to match it.
attributes = await oidc_response_to_user_attributes(failures=0)

assert attributes.localpart
if attributes.localpart is None:
# If no localpart is returned then we will generate one, so
# there is no need to search for existing users.
return None

user_id = UserID(attributes.localpart, self._server_name).to_string()
users = await self._store.get_users_by_id_case_insensitive(user_id)
Expand Down
9 changes: 8 additions & 1 deletion synapse/rest/synapse/client/new_user_consent.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ async def _async_render_GET(self, request: Request) -> None:
self._sso_handler.render_error(request, "bad_session", e.msg, code=e.code)
return

assert session.chosen_localpart
# It should be impossible to get here without having first been through
# the pick-a-username step, which ensures chosen_localpart gets set.
if not session.chosen_localpart:
logger.warning("Session has no user name selected")
self._sso_handler.render_error(
request, "no_user", "No user name has been selected.", code=400
)
return

user_id = UserID(session.chosen_localpart, self._server_name)
user_profile = {
Expand Down

0 comments on commit 1f72738

Please sign in to comment.