1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-06 12:02:40 +03:00

Fix some bad conversion artifacts

This commit is contained in:
Michael Telatynski
2021-08-10 10:34:05 +01:00
parent 1bcec53c6b
commit f876c35283

View File

@@ -193,12 +193,14 @@ export class InteractiveAuth {
private submitPromise: Promise<void> = null; private submitPromise: Promise<void> = null;
constructor(opts: IOpts) { constructor(opts: IOpts) {
this.matrixClient = opts.matrixClient;
this.data = opts.authData || {}; this.data = opts.authData || {};
this.requestCallback = opts.doRequest; this.requestCallback = opts.doRequest;
this.busyChangedCallback = opts.busyChanged; this.busyChangedCallback = opts.busyChanged;
// startAuthStage included for backwards compat // startAuthStage included for backwards compat
this.stateUpdatedCallback = opts.stateUpdated || opts.startAuthStage; this.stateUpdatedCallback = opts.stateUpdated || opts.startAuthStage;
this.requestEmailTokenCallback = opts.requestEmailToken; this.requestEmailTokenCallback = opts.requestEmailToken;
this.inputs = opts.inputs || {};
if (opts.sessionId) this.data.session = opts.sessionId; if (opts.sessionId) this.data.session = opts.sessionId;
this.clientSecret = opts.clientSecret || this.matrixClient.generateClientSecret(); 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 // This promise will be quite long-lived and will resolve when the
// request is authenticated and completes successfully. // request is authenticated and completes successfully.
this.attemptAuthDeferred = defer(); this.attemptAuthDeferred = defer();
const promise = this.attemptAuthDeferred.promise;
const hasFlows = this.data && this.data.flows; const hasFlows = this.data && this.data.flows;
@@ -236,7 +239,7 @@ export class InteractiveAuth {
this.startNextAuthStage(); this.startNextAuthStage();
} }
return this.attemptAuthDeferred.promise; return promise;
} }
/** /**
@@ -406,6 +409,7 @@ export class InteractiveAuth {
try { try {
const result = await this.requestCallback(auth, background); const result = await this.requestCallback(auth, background);
this.attemptAuthDeferred.resolve(result); this.attemptAuthDeferred.resolve(result);
this.attemptAuthDeferred = null;
} catch (error) { } catch (error) {
// sometimes UI auth errors don't come with flows // sometimes UI auth errors don't come with flows
const errorFlows = error.data ? error.data.flows : null; const errorFlows = error.data ? error.data.flows : null;
@@ -436,6 +440,7 @@ export class InteractiveAuth {
this.startNextAuthStage(); this.startNextAuthStage();
} catch (e) { } catch (e) {
this.attemptAuthDeferred.reject(e); this.attemptAuthDeferred.reject(e);
this.attemptAuthDeferred = null;
} }
if ( if (
@@ -470,12 +475,11 @@ export class InteractiveAuth {
// the failure up as the user can't complete auth if we can't // the failure up as the user can't complete auth if we can't
// send the email, for whatever reason. // send the email, for whatever reason.
this.attemptAuthDeferred.reject(e); this.attemptAuthDeferred.reject(e);
this.attemptAuthDeferred = null;
} finally { } finally {
this.requestingEmailToken = false; this.requestingEmailToken = false;
} }
} }
} finally {
this.attemptAuthDeferred = null; // TODO
} }
} }