Fix Error view not being displayed while an error exists

This commit is contained in:
Bubka 2023-11-21 15:06:49 +01:00
parent 73b2c60311
commit 9c818c69c5
2 changed files with 9 additions and 5 deletions

View File

@ -3,6 +3,7 @@ import middlewarePipeline from "@/router/middlewarePipeline";
import { useUserStore } from '@/stores/user'
import { useTwofaccounts } from '@/stores/twofaccounts'
import { useAppSettingsStore } from '@/stores/appSettings'
import { useNotifyStore } from '@/stores/notify'
import authGuard from './middlewares/authGuard'
import starter from './middlewares/starter'
@ -40,7 +41,7 @@ const router = createRouter({
{ path: '/webauthn/recover', name: 'webauthn.recover', component: () => import('../views/auth/webauthn/Recover.vue'), meta: { middlewares: [setReturnTo], disabledWithAuthProxy: true, showAbout: true } },
{ path: '/about', name: 'about', component: () => import('../views/About.vue'), meta: { showAbout: true } },
{ path: '/error', name: 'genericError', component: () => import('../views/Error.vue'), meta: { middlewares: [noEmptyError], err: null } },
{ path: '/error', name: 'genericError', component: () => import('../views/Error.vue'), meta: { middlewares: [noEmptyError] } },
{ path: '/404', name: '404', component: () => import('../views/Error.vue'), props: true },
{ path: '/:pathMatch(.*)*', name: 'notFound', component: () => import('../views/Error.vue'), props: true },
]
@ -51,7 +52,8 @@ router.beforeEach((to, from, next) => {
const user = useUserStore()
const twofaccounts = useTwofaccounts()
const appSettings = useAppSettingsStore()
const stores = { user: user, twofaccounts: twofaccounts, appSettings: appSettings }
const notify = useNotifyStore()
const stores = { user: user, twofaccounts: twofaccounts, appSettings: appSettings, notify: notify }
const nextMiddleware = {}
const context = { to, from, next, nextMiddleware, stores }

View File

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