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

Commit

Permalink
Fix formatting for "bad session" error during sso registration flow (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh authored Feb 3, 2021
1 parent 96e460d commit f20dadb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
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

0 comments on commit f20dadb

Please sign in to comment.