Altera login, add cookie e comeca lista de videos
This commit is contained in:
@@ -31,18 +31,24 @@ export const routes = [
|
||||
requiresAuth: true,
|
||||
title: "Vídeos",
|
||||
permissions: [roles.VIDEOS_LIST],
|
||||
showinModal: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/:pathMatch(.*)*",
|
||||
meta: {
|
||||
showinModal: false,
|
||||
},
|
||||
redirect: (to) => {
|
||||
return Cookies.get("token") ? "/videos" : "/login";
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/",
|
||||
meta: {
|
||||
showinModal: false,
|
||||
},
|
||||
redirect: (to) => {
|
||||
console.log(Cookies);
|
||||
return Cookies.get("token") ? "/videos" : "/login";
|
||||
},
|
||||
},
|
||||
@@ -69,32 +75,33 @@ const hasPermission = (requiredPermissions = []) => {
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.meta.title) {
|
||||
document.title = `${to.meta.title} | ClipperIA`;
|
||||
document.title = to.meta.title;
|
||||
}
|
||||
|
||||
if (to.matched.some((record) => record.meta.requiresAuth)) {
|
||||
if (!isAuthenticated()) {
|
||||
next({
|
||||
path: "/login",
|
||||
query: { redirect: to.fullPath },
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const requiredPermissions = to.meta.permissions || [];
|
||||
|
||||
if (requiredPermissions.length > 0 && !hasPermission(requiredPermissions)) {
|
||||
next({ path: "/unauthorized" });
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (to.matched.some((record) => record.meta.guest) && isAuthenticated()) {
|
||||
next({ path: "/" });
|
||||
// if (to.matched.some((record) => record.meta.requiresAuth)) {
|
||||
if (!isAuthenticated()) {
|
||||
next({
|
||||
path: "/login",
|
||||
query: { redirect: to.fullPath },
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// const requiredPermissions = to.meta.permissions || [];
|
||||
|
||||
// if (requiredPermissions.length > 0 && !hasPermission(requiredPermissions)) {
|
||||
// next({ path: "/unauthorized" });
|
||||
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (to.matched.some((record) => record.meta.guest) && isAuthenticated()) {
|
||||
// next({ path: "/" });
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user