Skip to content

Commit

Permalink
feat(middleware): add forbidden
Browse files Browse the repository at this point in the history
  • Loading branch information
dargmuesli committed May 13, 2023
1 parent 9432307 commit 15f0e8b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions nuxt/middleware/forbiddenNotAccount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { useMaevsiStore } from '~/store'

export default defineNuxtRouteMiddleware(() => {
const store = useMaevsiStore()

if (store.jwtDecoded.value?.role === 'maevsi_account') return

return abortNavigation({ statusCode: 403 })
})
9 changes: 9 additions & 0 deletions nuxt/middleware/forbiddenNotAnonymous.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { useMaevsiStore } from '~/store'

export default defineNuxtRouteMiddleware(() => {
const store = useMaevsiStore()

if (store.jwtDecoded.value?.role === 'maevsi_anonymous') return

return abortNavigation({ statusCode: 403 })
})

0 comments on commit 15f0e8b

Please sign in to comment.