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
pull/28217/head
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 React, { ChangeEvent, SyntheticEvent } from "react";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { Optional } from "matrix-events-sdk"; 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 { _t } from "../../../languageHandler";
import dis from "../../../dispatcher/dispatcher"; import dis from "../../../dispatcher/dispatcher";
@ -63,7 +63,6 @@ interface IProps {
interface IState { interface IState {
loginView: LoginView; loginView: LoginView;
keyBackupNeeded: boolean;
busy: boolean; busy: boolean;
password: string; password: string;
errorText: string; errorText: string;
@ -76,7 +75,6 @@ export default class SoftLogout extends React.Component<IProps, IState> {
this.state = { this.state = {
loginView: LoginView.Loading, loginView: LoginView.Loading,
keyBackupNeeded: true, // assume we do while we figure it out (see componentDidMount)
busy: false, busy: false,
password: "", password: "",
errorText: "", errorText: "",
@ -92,13 +90,6 @@ export default class SoftLogout extends React.Component<IProps, IState> {
} }
this.initLogin(); this.initLogin();
const cli = MatrixClientPeg.safeGet();
if (cli.isCryptoEnabled()) {
cli.countSessionsNeedingBackup().then((remaining) => {
this.setState({ keyBackupNeeded: remaining > 0 });
});
}
} }
private onClearAll = (): void => { private onClearAll = (): void => {
@ -278,41 +269,22 @@ export default class SoftLogout extends React.Component<IProps, IState> {
return <Spinner />; 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 (this.state.loginView === LoginView.Password) {
if (!introText) { return this.renderPasswordForm(_t("Enter your password to sign in and regain access to your account."));
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);
} }
if (this.state.loginView === LoginView.SSO || this.state.loginView === LoginView.CAS) { if (this.state.loginView === LoginView.SSO || this.state.loginView === LoginView.CAS) {
if (!introText) { return this.renderSsoForm(_t("Sign in and regain access to your account."));
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);
} }
if (this.state.loginView === LoginView.PasswordWithSocialSignOn) { 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 // We render both forms with no intro/error to ensure the layout looks reasonably
// okay enough. // okay enough.
// //
// Note: "mx_AuthBody_centered" text taken from registration page. // Note: "mx_AuthBody_centered" text taken from registration page.
return ( return (
<> <>
<p>{introText}</p> <p>{_t("Sign in and regain access to your account.")}</p>
{this.renderSsoForm(null)} {this.renderSsoForm(null)}
<h2 className="mx_AuthBody_centered"> <h2 className="mx_AuthBody_centered">
{_t("%(ssoButtons)s Or %(usernamePassword)s", { {_t("%(ssoButtons)s Or %(usernamePassword)s", {

View File

@ -3469,7 +3469,6 @@
"Incorrect password": "Incorrect password", "Incorrect password": "Incorrect password",
"Failed to re-authenticate": "Failed to re-authenticate", "Failed to re-authenticate": "Failed to re-authenticate",
"Forgotten your password?": "Forgotten your password?", "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.", "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.", "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.", "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> <div>
<form> <form>
<p> <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> </p>
<div <div
class="mx_Field mx_Field_input" class="mx_Field mx_Field_input"