mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-01-11 16:58:58 +01:00
Set up Not Found views
This commit is contained in:
parent
7cf8a70743
commit
27f3145740
4
resources/js_vue3/router/index.js
vendored
4
resources/js_vue3/router/index.js
vendored
@ -59,8 +59,8 @@ const router = createRouter({
|
||||
|
||||
{ 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' } },
|
||||
{ path: '/404', name: '404', component: Errors, props: true },
|
||||
{ path: '/:pathMatch(.*)*', name: 'notFound', component: Errors, props: true },
|
||||
|
||||
// Lazy loaded view
|
||||
{ path: '/about', name: 'about', component: () => import('../views/About.vue') }
|
||||
|
@ -66,11 +66,17 @@ export const httpClientFactory = (endpoint = 'api') => {
|
||||
return Promise.reject(error)
|
||||
}
|
||||
|
||||
// Not found
|
||||
if (error.response.status === 404) {
|
||||
useNotifyStore().notFound()
|
||||
return new Promise(() => {})
|
||||
}
|
||||
|
||||
// api calls are stateless so when user inactivity is detected
|
||||
// by the backend middleware, it cannot logout the user directly
|
||||
// so it returns a 418 response.
|
||||
// We catch the 418 response and log the user out
|
||||
if ( error.response.status === 418 ) {
|
||||
if (error.response.status === 418) {
|
||||
const user = useUserStore()
|
||||
user.logout()
|
||||
}
|
||||
|
4
resources/js_vue3/stores/notify.js
vendored
4
resources/js_vue3/stores/notify.js
vendored
@ -46,6 +46,10 @@ export const useNotifyStore = defineStore({
|
||||
//
|
||||
},
|
||||
|
||||
notFound(err) {
|
||||
router.push({ name: '404' })
|
||||
},
|
||||
|
||||
error(err) {
|
||||
this.parseError(err)
|
||||
router.push({ name: 'genericError' })
|
||||
|
@ -23,8 +23,8 @@
|
||||
|
||||
<template>
|
||||
<div class="error-message">
|
||||
<modal v-model="showModal" :closable="props.closable" @modal-closed="exit">
|
||||
<div class="error-message" v-if="$route.name == '404'">
|
||||
<modal v-model="showModal" :closable="props.closable">
|
||||
<div class="error-message" v-if="$route.name == '404' || $route.name == 'notFound'">
|
||||
<p class="error-404"></p>
|
||||
<p>{{ $t('errors.resource_not_found') }}</p>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user