Set up a global notification handler & Error view & Modal component

This commit is contained in:
Bubka
2023-09-28 11:27:45 +02:00
parent e37c0c9ea5
commit 73e36edd9c
7 changed files with 198 additions and 12 deletions

View File

@ -25,10 +25,11 @@ import SettingsOptions from '../views/settings/Options.vue'
// import SettingsWebAuthn from './views/settings/WebAuthn.vue'
// import EditCredential from './views/settings/Credentials/Edit.vue'
// import GeneratePAT from './views/settings/PATokens/Create.vue'
// import Errors from './views/Error.vue'
import Errors from '../views/Error.vue'
import About from '../views/About.vue'
import authGuard from './middlewares/authGuard'
import noEmptyError from './middlewares/noEmptyError'
const router = createRouter({
history: createWebHistory('/'),
@ -61,8 +62,8 @@ const router = createRouter({
{ path: '/webauthn/lost', name: 'webauthn.lost', component: WebauthnLost, meta: { disabledWithAuthProxy: true, showAbout: true } },
// { path: '/webauthn/recover', name: 'webauthn.recover', component: WebauthnRecover, meta: { disabledWithAuthProxy: true, showAbout: true } },
{ path: '/about', name: 'about',component: About, meta: { showAbout: true } },
// { path: '/error', name: 'genericError',component: Errors, props: true },
{ path: '/about', name: 'about', component: About, meta: { showAbout: true } },
{ path: '/error', name: 'genericError', component: Errors, meta: { middlewares: [noEmptyError], err: null } },
// { path: '/404', name: '404',component: Errors, props: true },
// { path: '*', redirect: { name: '404' } },

View File

@ -0,0 +1,8 @@
export default function noEmptyError({ to, next }) {
next()
if (to.params.err == undefined) {
// return to home if no err object is provided to prevent an empty error message
next({ name: 'accounts' });
}
else next()
}