Реализовал loginPage (иконка уведомлений в хедере - для выхода)

This commit is contained in:
megavrilinvv
2022-11-03 15:15:45 +03:00
parent 5ae67320d5
commit 996ef79e1a
10 changed files with 437 additions and 403 deletions

View File

@@ -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 },