migrate config away from localStorage; ensure config is properly loaded on access token auth

This commit is contained in:
Aine
2024-11-21 23:31:07 +02:00
parent eae00a6ccd
commit cfd8238edc
5 changed files with 68 additions and 112 deletions

View File

@@ -3,7 +3,7 @@ import { AuthProvider, HttpError, Options, fetchUtils } from "react-admin";
import storage from "../storage";
import { MatrixError, displayError } from "../components/error";
import { fetchAuthenticatedMedia } from "../utils/fetchMedia";
import { ClearConfig } from "../components/config";
import { FetchConfig, ClearConfig } from "../components/config";
const authProvider: AuthProvider = {
// called when the user attempts to log in
@@ -82,6 +82,11 @@ const authProvider: AuthProvider = {
storage.setItem("device_id", json.device_id);
storage.setItem("login_type", accessToken ? "accessToken" : "credentials");
// when doing access token auth, config is not fetched, so we need to do it here
if (accessToken) {
await FetchConfig();
}
return Promise.resolve({redirectTo: "/"});
} catch(err) {
const error = err as HttpError;