Skip to content

Commit

Permalink
fix access token breakage (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
H-Shay authored Oct 3, 2024
1 parent 7786bcc commit 448ca10
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import { initializeSentry, initializeGlobalPerformanceMetrics, patchMatrixClient
if (config.pantalaimon.use) {
const pantalaimon = new PantalaimonClient(config.homeserverUrl, storage);
client = await pantalaimon.createClientWithCredentials(config.pantalaimon.username, config.pantalaimon.password);
} else {
} else if (config.encryption.use) {
const accessToken = await Promise.resolve(storage.readValue("access_token"));
if (accessToken) {
client = new MatrixClient(config.homeserverUrl, accessToken, storage, cryptoStorage);
Expand All @@ -78,16 +78,15 @@ import { initializeSentry, initializeGlobalPerformanceMetrics, patchMatrixClient
const tempClient = await auth.passwordLogin(config.encryption.username, config.encryption.password)
client = new MatrixClient(config.homeserverUrl, tempClient.accessToken, storage, cryptoStorage);
}

try {
LogService.info("index", "Preparing encrypted client...")
await client.crypto.prepare();
} catch (e) {
LogService.error("Index", `Error preparing encrypted client ${e}`)
throw e
}


} else {
client = new MatrixClient(config.homeserverUrl, config.accessToken, storage);
}
patchMatrixClient();
config.RUNTIME.client = client;
Expand Down

0 comments on commit 448ca10

Please sign in to comment.