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.
pull/21833/head
Travis Ralston 2021-04-07 19:16:29 -06:00
parent 6e6a26f86a
commit 4ef3d176d9
2 changed files with 24 additions and 2 deletions

View File

@ -28,6 +28,7 @@ import {
} from '../../../stores/SetupEncryptionStore'; } from '../../../stores/SetupEncryptionStore';
import SetupEncryptionBody from "./SetupEncryptionBody"; import SetupEncryptionBody from "./SetupEncryptionBody";
import {replaceableComponent} from "../../../utils/replaceableComponent"; import {replaceableComponent} from "../../../utils/replaceableComponent";
import SecurityCustomisations from "../../../customisations/Security";
@replaceableComponent("structures.auth.CompleteSecurity") @replaceableComponent("structures.auth.CompleteSecurity")
export default class CompleteSecurity extends React.Component { export default class CompleteSecurity extends React.Component {
@ -45,6 +46,13 @@ export default class CompleteSecurity extends React.Component {
_onStoreUpdate = () => { _onStoreUpdate = () => {
const store = SetupEncryptionStore.sharedInstance(); 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}); this.setState({phase: store.phase});
}; };
@ -61,7 +69,9 @@ export default class CompleteSecurity extends React.Component {
let icon; let icon;
let title; 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; return null;
} else if (phase === PHASE_INTRO) { } else if (phase === PHASE_INTRO) {
icon = <span className="mx_CompleteSecurity_headerIcon mx_E2EIcon_warning" />; icon = <span className="mx_CompleteSecurity_headerIcon mx_E2EIcon_warning" />;

View File

@ -74,8 +74,20 @@ export interface ISecurityCustomisations {
catchAccessSecretStorageError?: typeof catchAccessSecretStorageError, catchAccessSecretStorageError?: typeof catchAccessSecretStorageError,
setupEncryptionNeeded?: typeof setupEncryptionNeeded, setupEncryptionNeeded?: typeof setupEncryptionNeeded,
getDehydrationKey?: typeof getDehydrationKey, 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 // A real customisation module will define and export one or more of the
// customisation points that make up `ISecurityCustomisations`. // customisation points that make up `ISecurityCustomisations`.
export default {} as ISecurityCustomisations; export default {
SHOW_ENCRYPTION_SETUP_UI: true,
} as ISecurityCustomisations;