From 8b4b0e0d391a645ed25caba1a7d4128c356bd49c Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 15 Mar 2017 11:15:35 +0000 Subject: [PATCH] Save the completed flows (#389) Otherwise we get very confused and go back to the start when given a response with no flows etc. Only copy data if none of the 3 fields are defined, since that's more the situation we actually want to handle. --- src/interactive-auth.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/interactive-auth.js b/src/interactive-auth.js index 8cc7d54de..821092787 100644 --- a/src/interactive-auth.js +++ b/src/interactive-auth.js @@ -272,10 +272,16 @@ InteractiveAuth.prototype = { // doesn't look like an interactive-auth failure. fail the whole lot. throw error; } - // if the error didn't come with flows or session ID, - // copy over the ones we have - if (!error.data.flows) error.data.flows = self._data.flows; - if (!error.data.session) error.data.session = self._data.session; + // if the error didn't come with flows, completed flows or session ID, + // copy over the ones we have. Synapse sometimes sends responses without + // any UI auth data (eg. when polling for email validation, if the email + // has not yet been validated). This appears to be a Synapse bug, which + // we workaround here. + if (!error.data.flows && !error.data.completed && !error.data.session) { + error.data.flows = self._data.flows; + error.data.completed = self._data.completed; + error.data.session = self._data.session; + } self._data = error.data; self._startNextAuthStage(); },