mirror of
https://gitlab.com/comunic/comunicconsole
synced 2024-12-25 13:08:52 +00:00
Can sign out
This commit is contained in:
parent
e75993b024
commit
1e6de3454f
@ -89,4 +89,18 @@ export class AccountHelper {
|
||||
if (currentAccount == null) throw new Error("Current account is null!");
|
||||
return currentAccount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sign out current user
|
||||
*/
|
||||
static async signOut() {
|
||||
try {
|
||||
await serverRequest("accounts/sign_out");
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
sessionStorage.removeItem(SESSION_STORAGE_TOKEN);
|
||||
document.location.href = document.location.href + "";
|
||||
}
|
||||
}
|
||||
|
@ -106,6 +106,11 @@ function Menu() {
|
||||
|
||||
export function MainRoute() {
|
||||
const classes = useStyles();
|
||||
|
||||
const signOut = () => {
|
||||
AccountHelper.signOut();
|
||||
};
|
||||
|
||||
return (
|
||||
<Router>
|
||||
<AppBar
|
||||
@ -130,7 +135,7 @@ export function MainRoute() {
|
||||
<small>{AccountHelper.currentAccount.email}</small>
|
||||
</Typography>
|
||||
|
||||
<IconButton aria-label="delete">
|
||||
<IconButton aria-label="delete" onClick={signOut}>
|
||||
<CloseSharpIcon />
|
||||
</IconButton>
|
||||
</Toolbar>
|
||||
|
Loading…
Reference in New Issue
Block a user