diff --git a/src/App.vue b/src/App.vue index 36de214..33cbb25 100644 --- a/src/App.vue +++ b/src/App.vue @@ -22,8 +22,8 @@ Admin - - Register + + Log out diff --git a/src/router/index.ts b/src/router/index.ts index 93ba92b..d9053dd 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -5,19 +5,15 @@ import { } from 'vue-router'; import RegisterView from '@/views/RegisterView.vue'; import LoginView from '@/views/LoginView.vue'; -import { - Privileges, - SuccessResponse, -} from '@/api/types'; +import { Privileges } from '@/api/types'; import HomeView from '@/views/HomeView.vue'; import FundView from '@/views/FundView.vue'; import AddFundView from '@/views/AddFundView.vue'; -import hasPermission from '@/lib/auth'; import AdminView from '@/views/AdminView.vue'; import ModifyQueueView from '@/views/ModifyQueueView.vue'; import AdminDashboardView from '@/views/AdminDashboardView.vue'; -import { usersExist } from '@/api/composed'; import ModifyUserView from '@/views/ModifyUserView.vue'; +import LogoutView from '@/views/LogoutView.vue'; const routes: Array = [ { @@ -39,17 +35,9 @@ const routes: Array = [ meta: { title: 'Login' }, }, { - path: '/register', - name: 'register', - component: RegisterView, - meta: { - requiredRights: Privileges.AdminPlus, - accessible: async () => { - const canProceed = await usersExist(); - return canProceed?.success; - }, - title: 'Register', - }, + path: '/logout', + name: 'logout', + component: LogoutView, }, { path: '/admin', @@ -126,6 +114,11 @@ const routes: Array = [ title: 'Administrator', }, }, + { + path: '/:pathMatch(.*)*', + name: 'wildcard', + redirect: '/', + }, ]; const router = createRouter({ @@ -136,16 +129,7 @@ const router = createRouter({ router.beforeEach(async (to, from, next) => { document.title = `Beignet - ${to.meta.title}`; - const requiredRights = to.meta.requiredRights as number | undefined; - const accessible = to.meta.accessible as (() => SuccessResponse) | undefined; - const allowed = requiredRights ? hasPermission(requiredRights) - || (accessible && !accessible().success) : true; - - if (allowed) { - next(); - } else { - next('/'); - } + return next(); }); export default router; diff --git a/src/views/LogoutView.vue b/src/views/LogoutView.vue new file mode 100644 index 0000000..7e80bf3 --- /dev/null +++ b/src/views/LogoutView.vue @@ -0,0 +1,20 @@ + + + + + diff --git a/src/views/ModifyUserView.vue b/src/views/ModifyUserView.vue index 8a982fa..91fe1fc 100644 --- a/src/views/ModifyUserView.vue +++ b/src/views/ModifyUserView.vue @@ -1,39 +1,47 @@ @@ -49,8 +57,12 @@ import jwtDecode from 'jwt-decode'; import store from '@/store'; const users = ref(); -const resp = await getUsers(); -users.value = resp?.users; +try { + const resp = await getUsers(); + users.value = resp?.users; +} catch { + users.value = undefined; +} const userData = ref({ username: '',