generated from Flycro/laravel-nuxt
fix: Dont run Role Middleware on the Server
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
829fc93c98
commit
f52415346e
|
|
@ -2,13 +2,17 @@ export default defineNuxtRouteMiddleware((to, from) => {
|
|||
const nuxtApp = useNuxtApp()
|
||||
const auth = useAuthStore()
|
||||
|
||||
if (process.server) {
|
||||
return
|
||||
}
|
||||
|
||||
if (auth.isLoggedIn && !auth.user.roles.includes('admin')) {
|
||||
return nuxtApp.runWithContext(() => {
|
||||
useToast().add({
|
||||
icon: "i-heroicons-exclamation-circle-solid",
|
||||
title: "Access denied.",
|
||||
color: "red",
|
||||
});
|
||||
icon: 'i-heroicons-exclamation-circle-solid',
|
||||
title: 'Access denied.',
|
||||
color: 'red',
|
||||
})
|
||||
|
||||
return navigateTo('/')
|
||||
})
|
||||
|
|
|
|||
|
|
@ -2,13 +2,17 @@ export default defineNuxtRouteMiddleware((to, from) => {
|
|||
const nuxtApp = useNuxtApp()
|
||||
const auth = useAuthStore()
|
||||
|
||||
if (process.server) {
|
||||
return
|
||||
}
|
||||
|
||||
if (auth.isLoggedIn && !auth.user.roles.includes('user')) {
|
||||
return nuxtApp.runWithContext(() => {
|
||||
useToast().add({
|
||||
icon: "i-heroicons-exclamation-circle-solid",
|
||||
title: "Access denied.",
|
||||
color: "red",
|
||||
});
|
||||
icon: 'i-heroicons-exclamation-circle-solid',
|
||||
title: 'Access denied.',
|
||||
color: 'red',
|
||||
})
|
||||
|
||||
return navigateTo('/')
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue