Skip to content

Commit

Permalink
frontend: add soft redirects on admin restricted pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Synar committed Jul 3, 2024
1 parent 7f1b7e6 commit 99b9dcf
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 8 deletions.
3 changes: 3 additions & 0 deletions frontend/pages/admin/families/[id]/comments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ definePageMeta({
layout: 'admin-ui',
})
if (!state.is_admin)
navigateTo('/admin/home')
const id = useRoute().params.id as string
const fetchedFamily = await state.client.getFamily(id)
Expand Down
3 changes: 3 additions & 0 deletions frontend/pages/admin/families/[id]/entities.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ definePageMeta({
layout: 'admin-ui',
})
if (!state.is_admin)
navigateTo('/admin/home')
const id = useRoute().params.id as string
const fetchedFamily = await state.client.getFamily(id)
Expand Down
3 changes: 3 additions & 0 deletions frontend/pages/admin/families/[id]/general.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ definePageMeta({
layout: 'admin-ui',
})
if (!state.is_admin)
navigateTo('/admin/home')
const id = useRoute().params.id as string
const fetchedFamily = await state.client.getFamily(id)
Expand Down
18 changes: 10 additions & 8 deletions frontend/pages/admin/families/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,16 @@ const initAdminLayout = inject<InitAdminLayout>('initAdminLayout')!
initAdminLayout(
'Familles',
'family',
[
{
icon: 'add',
label: 'Nouvelle famille',
severity: 'success',
url: `/admin/families/new`,
},
],
state.is_admin
? [
{
icon: 'add',
label: 'Nouvelle famille',
severity: 'success',
url: `/admin/families/new`,
},
]
: [],
[
{ label: 'Familles', url: '/admin/families' },
],
Expand Down
3 changes: 3 additions & 0 deletions frontend/pages/admin/families/new-icon-[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ definePageMeta({
layout: 'admin-ui',
})
if (!state.is_admin)
navigateTo('/admin/home')
const id = useRoute().params.id as string
const fetchedFamily = await state.fetchFamily(id)
Expand Down
3 changes: 3 additions & 0 deletions frontend/pages/admin/families/new.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ definePageMeta({
layout: 'admin-ui',
})
if (!state.is_admin)
navigateTo('/admin/home')
if (state.families == undefined)
await state.fetchFamilies()
Expand Down
3 changes: 3 additions & 0 deletions frontend/pages/admin/users/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ import type { NewOrUpdatedUser } from '~/lib'
import state from '~/lib/admin-state'
import { isValidText } from '~/lib/validation'
if (!state.is_admin)
navigateTo('/admin/home')
const userId = useRoute().params.id as string
const isNew = (userId === 'new')
Expand Down
3 changes: 3 additions & 0 deletions frontend/pages/admin/users/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ definePageMeta({
layout: 'admin-ui',
})
if (!state.is_admin)
navigateTo('/admin/home')
const initAdminLayout = inject<InitAdminLayout>('initAdminLayout')!
initAdminLayout(
'Utilisateur⋅ices',
Expand Down

0 comments on commit 99b9dcf

Please sign in to comment.