From 18866e3856344dcdbb4e423dae6d529d24a1111a Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Thu, 24 Aug 2023 14:27:32 +0100 Subject: [PATCH] Fix incompatibility of Soft Logout with Element-R (#11468) * Fix incompatibility of Soft Logout with Element-R This `countSessionsNeedingBackup` isn't available in Element-R, and I don't really understand the logic behind changing the message when we have sessions that are awaiting backup. Let's just rip it out. * i18n * update snapshot --- src/components/structures/auth/SoftLogout.tsx | 36 +++---------------- src/i18n/strings/en_EN.json | 1 - .../__snapshots__/MatrixChat-test.tsx.snap | 2 +- 3 files changed, 5 insertions(+), 34 deletions(-) diff --git a/src/components/structures/auth/SoftLogout.tsx b/src/components/structures/auth/SoftLogout.tsx index d52370f789d..57a39c74426 100644 --- a/src/components/structures/auth/SoftLogout.tsx +++ b/src/components/structures/auth/SoftLogout.tsx @@ -17,7 +17,7 @@ limitations under the License. import React, { ChangeEvent, SyntheticEvent } from "react"; import { logger } from "matrix-js-sdk/src/logger"; import { Optional } from "matrix-events-sdk"; -import { SSOFlow, LoginFlow, SSOAction, MatrixError } from "matrix-js-sdk/src/matrix"; +import { LoginFlow, MatrixError, SSOAction, SSOFlow } from "matrix-js-sdk/src/matrix"; import { _t } from "../../../languageHandler"; import dis from "../../../dispatcher/dispatcher"; @@ -63,7 +63,6 @@ interface IProps { interface IState { loginView: LoginView; - keyBackupNeeded: boolean; busy: boolean; password: string; errorText: string; @@ -76,7 +75,6 @@ export default class SoftLogout extends React.Component { this.state = { loginView: LoginView.Loading, - keyBackupNeeded: true, // assume we do while we figure it out (see componentDidMount) busy: false, password: "", errorText: "", @@ -92,13 +90,6 @@ export default class SoftLogout extends React.Component { } this.initLogin(); - - const cli = MatrixClientPeg.safeGet(); - if (cli.isCryptoEnabled()) { - cli.countSessionsNeedingBackup().then((remaining) => { - this.setState({ keyBackupNeeded: remaining > 0 }); - }); - } } private onClearAll = (): void => { @@ -278,41 +269,22 @@ export default class SoftLogout extends React.Component { return ; } - let introText: string | null = null; // null is translated to something area specific in this function - if (this.state.keyBackupNeeded) { - introText = _t( - "Regain access to your account and recover encryption keys stored in this session. Without them, you won't be able to read all of your secure messages in any session.", - ); - } - if (this.state.loginView === LoginView.Password) { - if (!introText) { - introText = _t("Enter your password to sign in and regain access to your account."); - } // else we already have a message and should use it (key backup warning) - - return this.renderPasswordForm(introText); + return this.renderPasswordForm(_t("Enter your password to sign in and regain access to your account.")); } if (this.state.loginView === LoginView.SSO || this.state.loginView === LoginView.CAS) { - if (!introText) { - introText = _t("Sign in and regain access to your account."); - } // else we already have a message and should use it (key backup warning) - - return this.renderSsoForm(introText); + return this.renderSsoForm(_t("Sign in and regain access to your account.")); } if (this.state.loginView === LoginView.PasswordWithSocialSignOn) { - if (!introText) { - introText = _t("Sign in and regain access to your account."); - } - // We render both forms with no intro/error to ensure the layout looks reasonably // okay enough. // // Note: "mx_AuthBody_centered" text taken from registration page. return ( <> -

{introText}

+

{_t("Sign in and regain access to your account.")}

{this.renderSsoForm(null)}

{_t("%(ssoButtons)s Or %(usernamePassword)s", { diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 294f29869c8..1deaf7b5b63 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -3469,7 +3469,6 @@ "Incorrect password": "Incorrect password", "Failed to re-authenticate": "Failed to re-authenticate", "Forgotten your password?": "Forgotten your password?", - "Regain access to your account and recover encryption keys stored in this session. Without them, you won't be able to read all of your secure messages in any session.": "Regain access to your account and recover encryption keys stored in this session. Without them, you won't be able to read all of your secure messages in any session.", "Enter your password to sign in and regain access to your account.": "Enter your password to sign in and regain access to your account.", "Sign in and regain access to your account.": "Sign in and regain access to your account.", "You cannot sign in to your account. Please contact your homeserver admin for more information.": "You cannot sign in to your account. Please contact your homeserver admin for more information.", diff --git a/test/components/structures/__snapshots__/MatrixChat-test.tsx.snap b/test/components/structures/__snapshots__/MatrixChat-test.tsx.snap index baf1a334105..9f71bf91cef 100644 --- a/test/components/structures/__snapshots__/MatrixChat-test.tsx.snap +++ b/test/components/structures/__snapshots__/MatrixChat-test.tsx.snap @@ -246,7 +246,7 @@ exports[` with a soft-logged-out session should show the soft-logo

- Regain access to your account and recover encryption keys stored in this session. Without them, you won't be able to read all of your secure messages in any session. + Enter your password to sign in and regain access to your account.