watch for browser back button press and update

This commit is contained in:
Fran Jurmanović
2021-05-29 21:33:07 +02:00
parent fdb3eb5a0f
commit 1c346346f2
4 changed files with 18 additions and 8 deletions

View File

@@ -25,11 +25,11 @@ class AppMainElement extends HTMLElement {
path: "/",
component: "home-page",
layout: "menu-layout",
middleware: this.middleAuth,
},
{
path: "/home",
component: "home-page",
middleware: this.isAuth,
},
{
path: "/rb",
@@ -47,12 +47,16 @@ class AppMainElement extends HTMLElement {
this.routerService.init();
}
isAuth = () => {
if (this.authStore?.token == null) {
middleAuth = () => {
if (!this.isAuth) {
this.routerService.goTo("/unauthorized");
return true;
}
};
get isAuth(): boolean {
return this.authStore && this.authStore.token;
}
}
export type { AppMainElement };