Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Alba María Álvarez
/
front_recipes
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5344cbcd
authored
Aug 28, 2025
by
Alba María Álvarez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
perf(router): añadido acceso a Gestión solo para Admin
parent
13c51ea9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
src/router/index.js
src/router/index.js
View file @
5344cbcd
...
@@ -58,7 +58,7 @@ const routes = [
...
@@ -58,7 +58,7 @@ const routes = [
path
:
'/users/management'
,
path
:
'/users/management'
,
name
:
'UserManagement'
,
name
:
'UserManagement'
,
component
:
UserManagement
,
component
:
UserManagement
,
meta
:
{
requiresAuth
:
true
}
meta
:
{
requiresAuth
:
true
,
requiresAdmin
:
true
}
}
}
]
]
...
@@ -70,15 +70,15 @@ const router = createRouter({
...
@@ -70,15 +70,15 @@ const router = createRouter({
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
const
authStore
=
useAuthStore
();
const
authStore
=
useAuthStore
();
const
requiresAuth
=
to
.
matched
.
some
(
record
=>
record
.
meta
.
requiresAuth
);
const
requiresAuth
=
to
.
matched
.
some
(
record
=>
record
.
meta
.
requiresAuth
);
const
requiresAdmin
=
to
.
matched
.
some
(
record
=>
record
.
meta
.
requiresAdmin
);
// Si el usuario no está autenticado
if
(
requiresAuth
&&
!
authStore
.
isAuthenticated
)
{
if
(
requiresAuth
&&
!
authStore
.
isAuthenticated
)
{
next
({
path
:
'/auth/login'
});
next
({
path
:
'/auth/login'
});
}
else
if
(
requiresAdmin
&&
authStore
.
user
?.
role
!=
'Admin'
)
{
next
({
path
:
'/recipes'
});
}
else
{
}
else
{
next
();
next
();
}
}
// Si el usuario no es ADMIN ...
})
})
export
default
router
export
default
router
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment