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

Commit

Permalink
Fix incompatibility of Soft Logout with Element-R (#11468)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
richvdh authored Aug 24, 2023
1 parent aec2f1f commit 18866e3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 34 deletions.
36 changes: 4 additions & 32 deletions src/components/structures/auth/SoftLogout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -63,7 +63,6 @@ interface IProps {

interface IState {
loginView: LoginView;
keyBackupNeeded: boolean;
busy: boolean;
password: string;
errorText: string;
Expand All @@ -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: "",
Expand All @@ -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 => {
Expand Down Expand Up @@ -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", {
Expand Down
1 change: 0 additions & 1 deletion src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 18866e3

Please sign in to comment.