Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 4ef3d17

Browse files
committed
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.
1 parent 6e6a26f commit 4ef3d17

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/components/structures/auth/CompleteSecurity.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
} from '../../../stores/SetupEncryptionStore';
2929
import SetupEncryptionBody from "./SetupEncryptionBody";
3030
import {replaceableComponent} from "../../../utils/replaceableComponent";
31+
import SecurityCustomisations from "../../../customisations/Security";
3132

3233
@replaceableComponent("structures.auth.CompleteSecurity")
3334
export default class CompleteSecurity extends React.Component {
@@ -45,6 +46,13 @@ export default class CompleteSecurity extends React.Component {
4546

4647
_onStoreUpdate = () => {
4748
const store = SetupEncryptionStore.sharedInstance();
49+
50+
// Skip "you're done" phase if the UI isn't shown
51+
if (store.phase === PHASE_DONE && SecurityCustomisations.SHOW_ENCRYPTION_SETUP_UI === false) {
52+
this.props.onFinished(true);
53+
return;
54+
}
55+
4856
this.setState({phase: store.phase});
4957
};
5058

@@ -61,7 +69,9 @@ export default class CompleteSecurity extends React.Component {
6169
let icon;
6270
let title;
6371

64-
if (phase === PHASE_LOADING) {
72+
// If the encryption UI is hidden then we can simply return nothing - the UI doesn't
73+
// need to be running in order to set up encryption with the SecurityCustomisations.
74+
if (phase === PHASE_LOADING || SecurityCustomisations.SHOW_ENCRYPTION_SETUP_UI === false) {
6575
return null;
6676
} else if (phase === PHASE_INTRO) {
6777
icon = <span className="mx_CompleteSecurity_headerIcon mx_E2EIcon_warning" />;

src/customisations/Security.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,20 @@ export interface ISecurityCustomisations {
7474
catchAccessSecretStorageError?: typeof catchAccessSecretStorageError,
7575
setupEncryptionNeeded?: typeof setupEncryptionNeeded,
7676
getDehydrationKey?: typeof getDehydrationKey,
77+
78+
/**
79+
* When false, disables the post-login UI from showing. If there's
80+
* an error during setup, that will be shown to the user.
81+
*
82+
* Note: when this is set to false then the app will assume the user's
83+
* encryption is set up some other way which would circumvent the default
84+
* UI, such as by presenting alternative UI.
85+
*/
86+
SHOW_ENCRYPTION_SETUP_UI?: boolean, // default true
7787
}
7888

7989
// A real customisation module will define and export one or more of the
8090
// customisation points that make up `ISecurityCustomisations`.
81-
export default {} as ISecurityCustomisations;
91+
export default {
92+
SHOW_ENCRYPTION_SETUP_UI: true,
93+
} as ISecurityCustomisations;

0 commit comments

Comments
 (0)