Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Commit c1ad5e4

Browse files
committed
Remove remaining old dehydration
1 parent 1d3ca7a commit c1ad5e4

File tree

4 files changed

+5
-68
lines changed

4 files changed

+5
-68
lines changed

src/Lifecycle.ts

-37
Original file line numberDiff line numberDiff line change
@@ -664,43 +664,6 @@ export async function setLoggedIn(credentials: IMatrixClientCreds): Promise<Matr
664664
return doSetLoggedIn(Object.assign({}, credentials, { pickleKey }), true, true);
665665
}
666666

667-
/**
668-
* Hydrates an existing session by using the credentials provided. This will
669-
* not clear any local storage, unlike setLoggedIn().
670-
*
671-
* Stops the existing Matrix client (without clearing its data) and starts a
672-
* new one in its place. This additionally starts all other react-sdk services
673-
* which use the new Matrix client.
674-
*
675-
* If the credentials belong to a different user from the session already stored,
676-
* the old session will be cleared automatically.
677-
*
678-
* @param {IMatrixClientCreds} credentials The credentials to use
679-
*
680-
* @returns {Promise} promise which resolves to the new MatrixClient once it has been started
681-
*/
682-
export async function hydrateSession(credentials: IMatrixClientCreds): Promise<MatrixClient> {
683-
const oldUserId = MatrixClientPeg.safeGet().getUserId();
684-
const oldDeviceId = MatrixClientPeg.safeGet().getDeviceId();
685-
686-
stopMatrixClient(); // unsets MatrixClientPeg.get()
687-
localStorage.removeItem("mx_soft_logout");
688-
_isLoggingOut = false;
689-
690-
const overwrite = credentials.userId !== oldUserId || credentials.deviceId !== oldDeviceId;
691-
if (overwrite) {
692-
logger.warn("Clearing all data: Old session belongs to a different user/session");
693-
}
694-
695-
if (!credentials.pickleKey && credentials.deviceId !== undefined) {
696-
logger.info("Lifecycle#hydrateSession: Pickle key not provided - trying to get one");
697-
credentials.pickleKey =
698-
(await PlatformPeg.get()?.getPickleKey(credentials.userId, credentials.deviceId)) ?? undefined;
699-
}
700-
701-
return doSetLoggedIn(credentials, overwrite, false);
702-
}
703-
704667
/**
705668
* When we have a authenticated via OIDC-native flow and have a refresh token
706669
* try to create a token refresher.

src/SecurityManager.ts

-7
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,6 @@ async function doAccessSecretStorage(func: () => Promise<void>, forceReset: bool
275275
});
276276
logger.debug("accessSecretStorage: bootstrapSecretStorage");
277277
await crypto.bootstrapSecretStorage({});
278-
279-
const keyId = Object.keys(secretStorageKeys)[0];
280-
if (!keyId) {
281-
logger.warn("accessSecretStorage: Not setting dehydration key: no SSSS key found");
282-
} else {
283-
logger.log("accessSecretStorage: Not setting dehydration key: feature disabled");
284-
}
285278
}
286279

287280
logger.debug("accessSecretStorage: 4S now ready");

src/components/structures/auth/SoftLogout.tsx

+5-23
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { _t } from "../../../languageHandler";
1515
import dis from "../../../dispatcher/dispatcher";
1616
import * as Lifecycle from "../../../Lifecycle";
1717
import Modal from "../../../Modal";
18-
import { IMatrixClientCreds, MatrixClientPeg } from "../../../MatrixClientPeg";
18+
import { MatrixClientPeg } from "../../../MatrixClientPeg";
1919
import { sendLoginRequest } from "../../../Login";
2020
import AuthPage from "../../views/auth/AuthPage";
2121
import { SSO_HOMESERVER_URL_KEY, SSO_ID_SERVER_URL_KEY } from "../../../BasePlatform";
@@ -148,9 +148,8 @@ export default class SoftLogout extends React.Component<IProps, IState> {
148148
device_id: cli.getDeviceId() ?? undefined,
149149
};
150150

151-
let credentials: IMatrixClientCreds;
152151
try {
153-
credentials = await sendLoginRequest(hsUrl, isUrl, loginType, loginParams);
152+
await sendLoginRequest(hsUrl, isUrl, loginType, loginParams);
154153
} catch (e) {
155154
let errorText = _t("auth|failed_soft_logout_homeserver");
156155
if (
@@ -167,11 +166,6 @@ export default class SoftLogout extends React.Component<IProps, IState> {
167166
});
168167
return;
169168
}
170-
171-
Lifecycle.hydrateSession(credentials).catch((e) => {
172-
logger.error(e);
173-
this.setState({ busy: false, errorText: _t("auth|failed_soft_logout_auth") });
174-
});
175169
};
176170

177171
/**
@@ -195,27 +189,15 @@ export default class SoftLogout extends React.Component<IProps, IState> {
195189
device_id: MatrixClientPeg.safeGet().getDeviceId() ?? undefined,
196190
};
197191

198-
let credentials: IMatrixClientCreds;
199192
try {
200-
credentials = await sendLoginRequest(hsUrl, isUrl, loginType, loginParams);
193+
await sendLoginRequest(hsUrl, isUrl, loginType, loginParams);
194+
this.props.onTokenLoginCompleted();
195+
return true;
201196
} catch (e) {
202197
logger.error(e);
203198
this.setState({ busy: false, loginView: LoginView.Unsupported });
204199
return false;
205200
}
206-
207-
return Lifecycle.hydrateSession(credentials)
208-
.then(() => {
209-
if (this.props.onTokenLoginCompleted) {
210-
this.props.onTokenLoginCompleted();
211-
}
212-
return true;
213-
})
214-
.catch((e) => {
215-
logger.error(e);
216-
this.setState({ busy: false, loginView: LoginView.Unsupported });
217-
return false;
218-
});
219201
}
220202

221203
private renderPasswordForm(introText: Optional<string>): JSX.Element {

src/i18n/strings/en_EN.json

-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@
206206
"failed_connect_identity_server_reset_password": "You can reset your password, but some features will be unavailable until the identity server is back online. If you keep seeing this warning, check your configuration or contact a server admin.",
207207
"failed_homeserver_discovery": "Failed to perform homeserver discovery",
208208
"failed_query_registration_methods": "Unable to query for supported registration methods.",
209-
"failed_soft_logout_auth": "Failed to re-authenticate",
210209
"failed_soft_logout_homeserver": "Failed to re-authenticate due to a homeserver problem",
211210
"footer_powered_by_matrix": "powered by Matrix",
212211
"forgot_password_email_invalid": "The email address doesn't appear to be valid.",

0 commit comments

Comments
 (0)