Wait for user to be verified in e2e setup
Wait for our user to become verified and cross-signing to be ready before declaring that we're finsihed, otherwise we could end up prompting the user to verify again if we just wait for the verification itself to complete. Fixes part of https://github.com/vector-im/riot-web/issues/13464pull/21833/head
parent
c7e663832a
commit
124740a63c
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
import EventEmitter from 'events';
|
import EventEmitter from 'events';
|
||||||
import { MatrixClientPeg } from '../MatrixClientPeg';
|
import { MatrixClientPeg } from '../MatrixClientPeg';
|
||||||
import { accessSecretStorage, AccessCancelledError } from '../CrossSigningManager';
|
import { accessSecretStorage, AccessCancelledError } from '../CrossSigningManager';
|
||||||
|
import { PHASE_DONE as VERIF_PHASE_DONE } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
|
||||||
|
|
||||||
export const PHASE_INTRO = 0;
|
export const PHASE_INTRO = 0;
|
||||||
export const PHASE_BUSY = 1;
|
export const PHASE_BUSY = 1;
|
||||||
|
@ -39,6 +40,7 @@ export class SetupEncryptionStore extends EventEmitter {
|
||||||
this.verificationRequest = null;
|
this.verificationRequest = null;
|
||||||
this.backupInfo = null;
|
this.backupInfo = null;
|
||||||
MatrixClientPeg.get().on("crypto.verification.request", this.onVerificationRequest);
|
MatrixClientPeg.get().on("crypto.verification.request", this.onVerificationRequest);
|
||||||
|
MatrixClientPeg.get().on('userTrustStatusChanged', this._onUserTrustStatusChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
|
@ -51,6 +53,7 @@ export class SetupEncryptionStore extends EventEmitter {
|
||||||
}
|
}
|
||||||
if (MatrixClientPeg.get()) {
|
if (MatrixClientPeg.get()) {
|
||||||
MatrixClientPeg.get().removeListener("crypto.verification.request", this.onVerificationRequest);
|
MatrixClientPeg.get().removeListener("crypto.verification.request", this.onVerificationRequest);
|
||||||
|
MatrixClientPeg.get().removeListener('userTrustStatusChanged', this._onUserTrustStatusChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,6 +105,15 @@ export class SetupEncryptionStore extends EventEmitter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onUserTrustStatusChanged = async (userId) => {
|
||||||
|
if (userId !== MatrixClientPeg.get().getUserId()) return;
|
||||||
|
const crossSigningReady = await MatrixClientPeg.get().isCrossSigningReady();
|
||||||
|
if (crossSigningReady) {
|
||||||
|
this.phase = PHASE_DONE;
|
||||||
|
this.emit("update");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onVerificationRequest = async (request) => {
|
onVerificationRequest = async (request) => {
|
||||||
if (request.otherUserId !== MatrixClientPeg.get().getUserId()) return;
|
if (request.otherUserId !== MatrixClientPeg.get().getUserId()) return;
|
||||||
|
|
||||||
|
@ -119,6 +131,14 @@ export class SetupEncryptionStore extends EventEmitter {
|
||||||
this.verificationRequest.off("change", this.onVerificationRequestChange);
|
this.verificationRequest.off("change", this.onVerificationRequestChange);
|
||||||
this.verificationRequest = null;
|
this.verificationRequest = null;
|
||||||
this.emit("update");
|
this.emit("update");
|
||||||
|
} else if (this.verificationRequest.phase === VERIF_PHASE_DONE) {
|
||||||
|
this.verificationRequest.off("change", this.onVerificationRequestChange);
|
||||||
|
this.verificationRequest = null;
|
||||||
|
// At this point, the verification has finished, we just need to wait for
|
||||||
|
// cross signing to be ready to use, so wait for the user trust status to
|
||||||
|
// change.
|
||||||
|
this.phase = PHASE_BUSY;
|
||||||
|
this.emit("update");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue