Enable key backup by default (#28691)
* Factor out crypto setup process into a store To make components pure and avoid react 18 dev mode problems due to components making requests when mounted. * fix test * test for the store * Add comment * Enable key backup by default When we set up cross signing, so the key backup key will be stored locally along with the cross signing keys until the user sets up recovery (4s). This will mean that a user can restore their backup if they log in on a new device as long as they verify with the one they registered on. Replaces https://github.com/element-hq/element-web/pull/28267 * Fix test * Prompt user to set up 4S on logout * Fix test * Add playwright test for key backup by default * Fix imports * This isn't unexpected anymore * Update doc * Fix docs and function name on renderSetupBackupDialog() * Use checkKeyBackupAndEnable * Docs for setup encryption toast * Also test the toast appears * Update mock for the method we use now * Okay fine I guess we need both * Swap here too * Fix comment & doc comments
This commit is contained in:
@@ -38,6 +38,9 @@ enum BackupStatus {
|
||||
/** there is a backup on the server but we are not backing up to it */
|
||||
SERVER_BACKUP_BUT_DISABLED,
|
||||
|
||||
/** Key backup is set up but recovery (4s) is not */
|
||||
BACKUP_NO_RECOVERY,
|
||||
|
||||
/** backup is not set up locally and there is no backup on the server */
|
||||
NO_BACKUP,
|
||||
|
||||
@@ -104,7 +107,11 @@ export default class LogoutDialog extends React.Component<IProps, IState> {
|
||||
}
|
||||
|
||||
if ((await crypto.getActiveSessionBackupVersion()) !== null) {
|
||||
this.setState({ backupStatus: BackupStatus.BACKUP_ACTIVE });
|
||||
if (await crypto.isSecretStorageReady()) {
|
||||
this.setState({ backupStatus: BackupStatus.BACKUP_ACTIVE });
|
||||
} else {
|
||||
this.setState({ backupStatus: BackupStatus.BACKUP_NO_RECOVERY });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -164,13 +171,17 @@ export default class LogoutDialog extends React.Component<IProps, IState> {
|
||||
};
|
||||
|
||||
/**
|
||||
* Show a dialog prompting the user to set up key backup.
|
||||
* Show a dialog prompting the user to set up their recovery method.
|
||||
*
|
||||
* Either there is no backup at all ({@link BackupStatus.NO_BACKUP}), there is a backup on the server but
|
||||
* we are not connected to it ({@link BackupStatus.SERVER_BACKUP_BUT_DISABLED}), or we were unable to pull the
|
||||
* backup data ({@link BackupStatus.ERROR}). In all three cases, we should prompt the user to set up key backup.
|
||||
* Either:
|
||||
* * There is no backup at all ({@link BackupStatus.NO_BACKUP})
|
||||
* * There is a backup set up but recovery (4s) is not ({@link BackupStatus.BACKUP_NO_RECOVERY})
|
||||
* * There is a backup on the server but we are not connected to it ({@link BackupStatus.SERVER_BACKUP_BUT_DISABLED})
|
||||
* * We were unable to pull the backup data ({@link BackupStatus.ERROR}).
|
||||
*
|
||||
* In all four cases, we should prompt the user to set up a method of recovery.
|
||||
*/
|
||||
private renderSetupBackupDialog(): React.ReactNode {
|
||||
private renderSetupRecoveryMethod(): React.ReactNode {
|
||||
const description = (
|
||||
<div>
|
||||
<p>{_t("auth|logout_dialog|setup_secure_backup_description_1")}</p>
|
||||
@@ -254,7 +265,8 @@ export default class LogoutDialog extends React.Component<IProps, IState> {
|
||||
case BackupStatus.NO_BACKUP:
|
||||
case BackupStatus.SERVER_BACKUP_BUT_DISABLED:
|
||||
case BackupStatus.ERROR:
|
||||
return this.renderSetupBackupDialog();
|
||||
case BackupStatus.BACKUP_NO_RECOVERY:
|
||||
return this.renderSetupRecoveryMethod();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user