Skip to content

Commit

Permalink
Merge pull request #1305 from matrix-org/dbkr/uia_ignore_poll_after_s…
Browse files Browse the repository at this point in the history
…uccess

Avoid creating two devices on registration
  • Loading branch information
dbkr committed Apr 7, 2020
2 parents 62380a4 + 6ad4d6d commit 66417e6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/interactive-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ InteractiveAuth.prototype = {
*/
poll: async function() {
if (!this._data.session) return;
// likewise don't poll if there is no auth session in progress
if (!this._resolveFunc) return;
// if we currently have a request in flight, there's no point making
// another just to check what the status is
if (this._submitPromise) return;
Expand Down Expand Up @@ -318,6 +320,8 @@ InteractiveAuth.prototype = {
try {
const result = await this._requestCallback(auth, background);
this._resolveFunc(result);
this._resolveFunc = null;
this._rejectFunc = null;
} catch (error) {
// sometimes UI auth errors don't come with flows
const errorFlows = error.data ? error.data.flows : null;
Expand Down Expand Up @@ -379,8 +383,10 @@ InteractiveAuth.prototype = {
// (or not being registered, depending on what we're trying
// to do) or it could be a network failure. Either way, pass
// the failure up as the user can't complete auth if we can't
// send the email, foe whatever reason.
// send the email, for whatever reason.
this._rejectFunc(e);
this._resolveFunc = null;
this._rejectFunc = null;
} finally {
this._requestingEmailToken = false;
}
Expand Down

0 comments on commit 66417e6

Please sign in to comment.