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

Fix formatting for "bad session" error during sso registration flow #9296

Merged
merged 1 commit into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/9296.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug in Synapse 1.27.0rc1 which meant the "session expired" error page during SSO registration was badly formatted.
19 changes: 16 additions & 3 deletions synapse/handlers/sso.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,11 @@ async def handle_submit_username_request(
use_display_name: whether the user wants to use the suggested display name
emails_to_use: emails that the user would like to use
"""
session = self.get_mapping_session(session_id)
try:
session = self.get_mapping_session(session_id)
except SynapseError as e:
self.render_error(request, "bad_session", e.msg, code=e.code)
return

# update the session with the user's choices
session.chosen_localpart = localpart
Expand Down Expand Up @@ -793,7 +797,12 @@ async def handle_terms_accepted(
session_id,
terms_version,
)
session = self.get_mapping_session(session_id)
try:
session = self.get_mapping_session(session_id)
except SynapseError as e:
self.render_error(request, "bad_session", e.msg, code=e.code)
return

session.terms_accepted_version = terms_version

# we're done; now we can register the user
Expand All @@ -808,7 +817,11 @@ async def register_sso_user(self, request: Request, session_id: str) -> None:
request: HTTP request
session_id: ID of the username mapping session, extracted from a cookie
"""
session = self.get_mapping_session(session_id)
try:
session = self.get_mapping_session(session_id)
except SynapseError as e:
self.render_error(request, "bad_session", e.msg, code=e.code)
return

logger.info(
"[session %s] Registering localpart %s",
Expand Down