mirror of
https://github.com/etkecc/synapse-admin.git
synced 2024-12-12 14:38:36 +03:00
clear storage on logout
This commit is contained in:
parent
6faebaf9df
commit
b925c63171
3 changed files with 21 additions and 4 deletions
|
@ -2,6 +2,7 @@ import { AppBar, TitlePortal, InspectorButton, Confirm, Layout, Logout, Menu, us
|
||||||
import { LoginMethod } from "../pages/LoginPage";
|
import { LoginMethod } from "../pages/LoginPage";
|
||||||
import { useEffect, useState, Suspense } from "react";
|
import { useEffect, useState, Suspense } from "react";
|
||||||
import { Icons, DefaultIcon } from "./icons";
|
import { Icons, DefaultIcon } from "./icons";
|
||||||
|
import { ClearConfig } from "./config";
|
||||||
|
|
||||||
const AdminUserMenu = () => {
|
const AdminUserMenu = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
@ -21,8 +22,7 @@ const AdminUserMenu = () => {
|
||||||
|
|
||||||
const handleDialogClose = () => {
|
const handleDialogClose = () => {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
localStorage.removeItem("access_token");
|
ClearConfig();
|
||||||
localStorage.removeItem("login_type");
|
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -68,3 +68,20 @@ export const LoadConfig = (context: Config): Config => {
|
||||||
} as Config;
|
} as Config;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ClearConfig = () => {
|
||||||
|
// config.json
|
||||||
|
storage.removeItem("restrict_base_url");
|
||||||
|
storage.removeItem("as_managed_users");
|
||||||
|
storage.removeItem("support_url");
|
||||||
|
storage.removeItem("menu");
|
||||||
|
|
||||||
|
// session
|
||||||
|
storage.removeItem("home_server");
|
||||||
|
storage.removeItem("base_url");
|
||||||
|
storage.removeItem("user_id");
|
||||||
|
storage.removeItem("device_id");
|
||||||
|
storage.removeItem("access_token");
|
||||||
|
storage.removeItem("login_type");
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { AuthProvider, HttpError, Options, fetchUtils } from "react-admin";
|
||||||
import storage from "../storage";
|
import storage from "../storage";
|
||||||
import { MatrixError, displayError } from "../components/error";
|
import { MatrixError, displayError } from "../components/error";
|
||||||
import { fetchAuthenticatedMedia } from "../utils/fetchMedia";
|
import { fetchAuthenticatedMedia } from "../utils/fetchMedia";
|
||||||
|
import { ClearConfig } from "../components/config";
|
||||||
|
|
||||||
const authProvider: AuthProvider = {
|
const authProvider: AuthProvider = {
|
||||||
// called when the user attempts to log in
|
// called when the user attempts to log in
|
||||||
|
@ -154,8 +155,7 @@ const authProvider: AuthProvider = {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("Error logging out", err);
|
console.log("Error logging out", err);
|
||||||
} finally {
|
} finally {
|
||||||
storage.removeItem("access_token");
|
ClearConfig();
|
||||||
storage.removeItem("login_type");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue