From 4ef3d176d9d633f1f100075f4c3c60379d66f34a Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 7 Apr 2021 19:16:29 -0600 Subject: [PATCH] Add ability to hide post-login encryption setup with customisation point This is primarily intended for alternative setup UI or where the customisations end up configuring encryption some other way. If used without respecting the warnings in the docs, the user could end up at a blank page - use with caution, and only as directed. --- src/components/structures/auth/CompleteSecurity.js | 12 +++++++++++- src/customisations/Security.ts | 14 +++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/components/structures/auth/CompleteSecurity.js b/src/components/structures/auth/CompleteSecurity.js index 49fcf20415..2c46fe9823 100644 --- a/src/components/structures/auth/CompleteSecurity.js +++ b/src/components/structures/auth/CompleteSecurity.js @@ -28,6 +28,7 @@ import { } from '../../../stores/SetupEncryptionStore'; import SetupEncryptionBody from "./SetupEncryptionBody"; import {replaceableComponent} from "../../../utils/replaceableComponent"; +import SecurityCustomisations from "../../../customisations/Security"; @replaceableComponent("structures.auth.CompleteSecurity") export default class CompleteSecurity extends React.Component { @@ -45,6 +46,13 @@ export default class CompleteSecurity extends React.Component { _onStoreUpdate = () => { const store = SetupEncryptionStore.sharedInstance(); + + // Skip "you're done" phase if the UI isn't shown + if (store.phase === PHASE_DONE && SecurityCustomisations.SHOW_ENCRYPTION_SETUP_UI === false) { + this.props.onFinished(true); + return; + } + this.setState({phase: store.phase}); }; @@ -61,7 +69,9 @@ export default class CompleteSecurity extends React.Component { let icon; let title; - if (phase === PHASE_LOADING) { + // If the encryption UI is hidden then we can simply return nothing - the UI doesn't + // need to be running in order to set up encryption with the SecurityCustomisations. + if (phase === PHASE_LOADING || SecurityCustomisations.SHOW_ENCRYPTION_SETUP_UI === false) { return null; } else if (phase === PHASE_INTRO) { icon = ; diff --git a/src/customisations/Security.ts b/src/customisations/Security.ts index 96b5b62cdb..e215c5cb24 100644 --- a/src/customisations/Security.ts +++ b/src/customisations/Security.ts @@ -74,8 +74,20 @@ export interface ISecurityCustomisations { catchAccessSecretStorageError?: typeof catchAccessSecretStorageError, setupEncryptionNeeded?: typeof setupEncryptionNeeded, getDehydrationKey?: typeof getDehydrationKey, + + /** + * When false, disables the post-login UI from showing. If there's + * an error during setup, that will be shown to the user. + * + * Note: when this is set to false then the app will assume the user's + * encryption is set up some other way which would circumvent the default + * UI, such as by presenting alternative UI. + */ + SHOW_ENCRYPTION_SETUP_UI?: boolean, // default true } // A real customisation module will define and export one or more of the // customisation points that make up `ISecurityCustomisations`. -export default {} as ISecurityCustomisations; +export default { + SHOW_ENCRYPTION_SETUP_UI: true, +} as ISecurityCustomisations;