Fix: Only allow admins to access admin views (#8361)
* fix(client): only allow admins to access /admin/* * fix(client): Also allow moderators to access admin panel
This commit is contained in:
parent
5448ed643e
commit
7f4551b769
|
@ -3,7 +3,7 @@ import { createRouter, createWebHistory } from 'vue-router';
|
||||||
import MkLoading from '@/pages/_loading_.vue';
|
import MkLoading from '@/pages/_loading_.vue';
|
||||||
import MkError from '@/pages/_error_.vue';
|
import MkError from '@/pages/_error_.vue';
|
||||||
import MkTimeline from '@/pages/timeline.vue';
|
import MkTimeline from '@/pages/timeline.vue';
|
||||||
import { $i } from './account';
|
import { $i, iAmModerator } from './account';
|
||||||
import { ui } from '@/config';
|
import { ui } from '@/config';
|
||||||
|
|
||||||
const page = (path: string, ui?: string) => defineAsyncComponent({
|
const page = (path: string, ui?: string) => defineAsyncComponent({
|
||||||
|
@ -67,8 +67,8 @@ const defaultRoutes = [
|
||||||
{ path: '/my/antennas/:antennaId', component: page('my-antennas/edit'), props: true },
|
{ path: '/my/antennas/:antennaId', component: page('my-antennas/edit'), props: true },
|
||||||
{ path: '/my/clips', component: page('my-clips/index') },
|
{ path: '/my/clips', component: page('my-clips/index') },
|
||||||
{ path: '/scratchpad', component: page('scratchpad') },
|
{ path: '/scratchpad', component: page('scratchpad') },
|
||||||
{ path: '/admin/:page(.*)?', component: page('admin/index'), props: route => ({ initialPage: route.params.page || null }) },
|
{ path: '/admin/:page(.*)?', component: iAmModerator ? page('admin/index') : page('not-found'), props: route => ({ initialPage: route.params.page || null }) },
|
||||||
{ path: '/admin', component: page('admin/index') },
|
{ path: '/admin', component: iAmModerator ? page('admin/index') : page('not-found') },
|
||||||
{ path: '/notes/:note', name: 'note', component: page('note'), props: route => ({ noteId: route.params.note }) },
|
{ path: '/notes/:note', name: 'note', component: page('note'), props: route => ({ noteId: route.params.note }) },
|
||||||
{ path: '/tags/:tag', component: page('tag'), props: route => ({ tag: route.params.tag }) },
|
{ path: '/tags/:tag', component: page('tag'), props: route => ({ tag: route.params.tag }) },
|
||||||
{ path: '/user-info/:user', component: page('user-info'), props: route => ({ userId: route.params.user }) },
|
{ path: '/user-info/:user', component: page('user-info'), props: route => ({ userId: route.params.user }) },
|
||||||
|
|
Loading…
Reference in New Issue