|
|
@ -10,6 +10,7 @@ const authProvider = {
|
|
|
|
type: "m.login.password",
|
|
|
|
type: "m.login.password",
|
|
|
|
user: username,
|
|
|
|
user: username,
|
|
|
|
password: password,
|
|
|
|
password: password,
|
|
|
|
|
|
|
|
initial_device_display_name: "Synapse Admin",
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -30,9 +31,24 @@ const authProvider = {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// called when the user clicks on the logout button
|
|
|
|
// called when the user clicks on the logout button
|
|
|
|
logout: () => {
|
|
|
|
logout: () => {
|
|
|
|
console.log("logout ");
|
|
|
|
console.log("logout");
|
|
|
|
localStorage.removeItem("access_token");
|
|
|
|
|
|
|
|
return Promise.resolve();
|
|
|
|
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");
|
|
|
|
|
|
|
|
localStorage.removeItem("device_id");
|
|
|
|
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// called when the API returns an error
|
|
|
|
// called when the API returns an error
|
|
|
|
checkError: ({ status }) => {
|
|
|
|
checkError: ({ status }) => {
|
|
|
|