mirror of
https://github.com/UA-Fediland/synapse-admin.git
synced 2024-11-10 00:34:51 +00:00
Fix broken redirect to login page (#116)
This commit is contained in:
parent
8ff0ac913c
commit
c6b6e54617
1 changed files with 10 additions and 7 deletions
|
@ -35,20 +35,23 @@ const authProvider = {
|
||||||
|
|
||||||
const logout_api_url =
|
const logout_api_url =
|
||||||
localStorage.getItem("base_url") + "/_matrix/client/r0/logout";
|
localStorage.getItem("base_url") + "/_matrix/client/r0/logout";
|
||||||
const token = localStorage.getItem("access_token");
|
const access_token = localStorage.getItem("access_token");
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
user: {
|
user: {
|
||||||
authenticated: true,
|
authenticated: true,
|
||||||
token: `Bearer ${token}`,
|
token: `Bearer ${access_token}`,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return fetchUtils.fetchJson(logout_api_url, options).then(({ json }) => {
|
if (typeof access_token === "string") {
|
||||||
|
fetchUtils.fetchJson(logout_api_url, options).then(({ json }) => {
|
||||||
localStorage.removeItem("access_token");
|
localStorage.removeItem("access_token");
|
||||||
localStorage.removeItem("device_id");
|
localStorage.removeItem("device_id");
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
return Promise.resolve();
|
||||||
},
|
},
|
||||||
// called when the API returns an error
|
// called when the API returns an error
|
||||||
checkError: ({ status }) => {
|
checkError: ({ status }) => {
|
||||||
|
@ -62,7 +65,7 @@ const authProvider = {
|
||||||
checkAuth: () => {
|
checkAuth: () => {
|
||||||
const access_token = localStorage.getItem("access_token");
|
const access_token = localStorage.getItem("access_token");
|
||||||
console.log("checkAuth " + access_token);
|
console.log("checkAuth " + access_token);
|
||||||
return typeof access_token == "string"
|
return typeof access_token === "string"
|
||||||
? Promise.resolve()
|
? Promise.resolve()
|
||||||
: Promise.reject();
|
: Promise.reject();
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue