Реализовал loginPage (иконка уведомлений в хедере - для выхода)
This commit is contained in:
@@ -5,16 +5,33 @@ import TheSettings from "@/pages/settings/TheSettings";
|
||||
import TheLogin from "@/pages/login/TheLogin";
|
||||
import LoggedInLayout from "@/components/LoggedInLayout";
|
||||
|
||||
const ifNotAuthenticated = (to, from, next) => {
|
||||
if (!localStorage.getItem("tokenAccess")) {
|
||||
return next();
|
||||
}
|
||||
next("/");
|
||||
};
|
||||
|
||||
const ifAuthenticated = (to, from, next) => {
|
||||
if (localStorage.getItem("tokenAccess")) {
|
||||
return next();
|
||||
}
|
||||
next("/login");
|
||||
};
|
||||
|
||||
export default createRouter({
|
||||
history: createWebHashHistory(),
|
||||
routes: [
|
||||
{
|
||||
path: "/login",
|
||||
component: TheLogin,
|
||||
beforeEnter: ifNotAuthenticated,
|
||||
},
|
||||
{
|
||||
path: "/",
|
||||
component: LoggedInLayout,
|
||||
beforeEnter: ifAuthenticated,
|
||||
|
||||
children: [
|
||||
{ path: "", redirect: "calendar" },
|
||||
{ path: "calendar", component: TheCalendar },
|
||||
|
||||
Reference in New Issue
Block a user