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

Commit 35e99d6

Browse files
authored
Fix Identity Server terms accepting not working as expected (#12109)
Signed-off-by: Michael Telatynski <[email protected]>
1 parent 578ae36 commit 35e99d6

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/IdentityAuthClient.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,13 @@ export default class IdentityAuthClient {
5757
}
5858
}
5959

60+
// This client must not be used for general operations as it may not have a baseUrl or be running (tempClient).
61+
private get identityClient(): MatrixClient {
62+
return this.tempClient ?? this.matrixClient;
63+
}
64+
6065
private get matrixClient(): MatrixClient {
61-
return this.tempClient ? this.tempClient : MatrixClientPeg.safeGet();
66+
return MatrixClientPeg.safeGet();
6267
}
6368

6469
private writeToken(): void {
@@ -117,10 +122,10 @@ export default class IdentityAuthClient {
117122
}
118123

119124
private async checkToken(token: string): Promise<void> {
120-
const identityServerUrl = this.matrixClient.getIdentityServerUrl()!;
125+
const identityServerUrl = this.identityClient.getIdentityServerUrl()!;
121126

122127
try {
123-
await this.matrixClient.getIdentityAccount(token);
128+
await this.identityClient.getIdentityAccount(token);
124129
} catch (e) {
125130
if (e instanceof MatrixError && e.errcode === "M_TERMS_NOT_SIGNED") {
126131
logger.log("Identity server requires new terms to be agreed to");
@@ -171,7 +176,8 @@ export default class IdentityAuthClient {
171176
public async registerForToken(check = true): Promise<string> {
172177
const hsOpenIdToken = await MatrixClientPeg.safeGet().getOpenIdToken();
173178
// XXX: The spec is `token`, but we used `access_token` for a Sydent release.
174-
const { access_token: accessToken, token } = await this.matrixClient.registerWithIdentityServer(hsOpenIdToken);
179+
const { access_token: accessToken, token } =
180+
await this.identityClient.registerWithIdentityServer(hsOpenIdToken);
175181
const identityAccessToken = token ? token : accessToken;
176182
if (check) await this.checkToken(identityAccessToken);
177183
return identityAccessToken;

0 commit comments

Comments
 (0)