From f876c3528307f38d3a03c04e8298cca3ff91a067 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 10 Aug 2021 10:34:05 +0100 Subject: [PATCH] Fix some bad conversion artifacts --- src/interactive-auth.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/interactive-auth.ts b/src/interactive-auth.ts index 5d6dcd83c..f74463409 100644 --- a/src/interactive-auth.ts +++ b/src/interactive-auth.ts @@ -193,12 +193,14 @@ export class InteractiveAuth { private submitPromise: Promise = null; constructor(opts: IOpts) { + this.matrixClient = opts.matrixClient; this.data = opts.authData || {}; this.requestCallback = opts.doRequest; this.busyChangedCallback = opts.busyChanged; // startAuthStage included for backwards compat this.stateUpdatedCallback = opts.stateUpdated || opts.startAuthStage; this.requestEmailTokenCallback = opts.requestEmailToken; + this.inputs = opts.inputs || {}; if (opts.sessionId) this.data.session = opts.sessionId; this.clientSecret = opts.clientSecret || this.matrixClient.generateClientSecret(); @@ -216,6 +218,7 @@ export class InteractiveAuth { // This promise will be quite long-lived and will resolve when the // request is authenticated and completes successfully. this.attemptAuthDeferred = defer(); + const promise = this.attemptAuthDeferred.promise; const hasFlows = this.data && this.data.flows; @@ -236,7 +239,7 @@ export class InteractiveAuth { this.startNextAuthStage(); } - return this.attemptAuthDeferred.promise; + return promise; } /** @@ -406,6 +409,7 @@ export class InteractiveAuth { try { const result = await this.requestCallback(auth, background); this.attemptAuthDeferred.resolve(result); + this.attemptAuthDeferred = null; } catch (error) { // sometimes UI auth errors don't come with flows const errorFlows = error.data ? error.data.flows : null; @@ -436,6 +440,7 @@ export class InteractiveAuth { this.startNextAuthStage(); } catch (e) { this.attemptAuthDeferred.reject(e); + this.attemptAuthDeferred = null; } if ( @@ -470,12 +475,11 @@ export class InteractiveAuth { // the failure up as the user can't complete auth if we can't // send the email, for whatever reason. this.attemptAuthDeferred.reject(e); + this.attemptAuthDeferred = null; } finally { this.requestingEmailToken = false; } } - } finally { - this.attemptAuthDeferred = null; // TODO } }