mirror of
https://github.com/Awesome-Technologies/synapse-admin.git
synced 2024-10-31 06:55:15 +03:00
Name device used by Synapse Admin and hook up logout button (#113)
* Name device used by Synapse Admin * Actually logout when the logout button is pressed so that old sessions get deleted * Fix lint
This commit is contained in:
parent
536ffc2fbf
commit
8adab0e927
1 changed files with 19 additions and 3 deletions
|
@ -10,6 +10,7 @@ const authProvider = {
|
|||
type: "m.login.password",
|
||||
user: username,
|
||||
password: password,
|
||||
initial_device_display_name: "Synapse Admin",
|
||||
}),
|
||||
};
|
||||
|
||||
|
@ -30,9 +31,24 @@ const authProvider = {
|
|||
},
|
||||
// called when the user clicks on the logout button
|
||||
logout: () => {
|
||||
console.log("logout ");
|
||||
console.log("logout");
|
||||
|
||||
const logout_api_url =
|
||||
localStorage.getItem("base_url") + "/_matrix/client/r0/logout";
|
||||
const token = localStorage.getItem("access_token");
|
||||
|
||||
const options = {
|
||||
method: "POST",
|
||||
user: {
|
||||
authenticated: true,
|
||||
token: `Bearer ${token}`,
|
||||
},
|
||||
};
|
||||
|
||||
return fetchUtils.fetchJson(logout_api_url, options).then(({ json }) => {
|
||||
localStorage.removeItem("access_token");
|
||||
return Promise.resolve();
|
||||
localStorage.removeItem("device_id");
|
||||
});
|
||||
},
|
||||
// called when the API returns an error
|
||||
checkError: ({ status }) => {
|
||||
|
|
Loading…
Reference in a new issue