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
This commit is contained in:
Richard van der Hoff 2023-08-24 14:27:32 +01:00 committed by GitHub
parent aec2f1f794
commit 18866e3856
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 34 deletions

View file

@ -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<IProps, IState> {
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<IProps, IState> {
}
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<IProps, IState> {
return <Spinner />;
}
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 (
<>
<p>{introText}</p>
<p>{_t("Sign in and regain access to your account.")}</p>
{this.renderSsoForm(null)}
<h2 className="mx_AuthBody_centered">
{_t("%(ssoButtons)s Or %(usernamePassword)s", {

View file

@ -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.",

View file

@ -246,7 +246,7 @@ exports[`<MatrixChat /> with a soft-logged-out session should show the soft-logo
<div>
<form>
<p>
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.
</p>
<div
class="mx_Field mx_Field_input"