mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-27 15:32:06 +02: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: '/about', name: 'about', component: About, meta: { showAbout: true } },
|
||||||
{ path: '/error', name: 'genericError', component: Errors, meta: { middlewares: [noEmptyError], err: null } },
|
{ path: '/error', name: 'genericError', component: Errors, meta: { middlewares: [noEmptyError], err: null } },
|
||||||
// { path: '/404', name: '404',component: Errors, props: true },
|
{ path: '/404', name: '404', component: Errors, props: true },
|
||||||
// { path: '*', redirect: { name: '404' } },
|
{ path: '/:pathMatch(.*)*', name: 'notFound', component: Errors, props: true },
|
||||||
|
|
||||||
// Lazy loaded view
|
// Lazy loaded view
|
||||||
{ path: '/about', name: 'about', component: () => import('../views/About.vue') }
|
{ path: '/about', name: 'about', component: () => import('../views/About.vue') }
|
||||||
|
@ -66,11 +66,17 @@ export const httpClientFactory = (endpoint = 'api') => {
|
|||||||
return Promise.reject(error)
|
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
|
// api calls are stateless so when user inactivity is detected
|
||||||
// by the backend middleware, it cannot logout the user directly
|
// by the backend middleware, it cannot logout the user directly
|
||||||
// so it returns a 418 response.
|
// so it returns a 418 response.
|
||||||
// We catch the 418 response and log the user out
|
// We catch the 418 response and log the user out
|
||||||
if ( error.response.status === 418 ) {
|
if (error.response.status === 418) {
|
||||||
const user = useUserStore()
|
const user = useUserStore()
|
||||||
user.logout()
|
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) {
|
error(err) {
|
||||||
this.parseError(err)
|
this.parseError(err)
|
||||||
router.push({ name: 'genericError' })
|
router.push({ name: 'genericError' })
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="error-message">
|
<div class="error-message">
|
||||||
<modal v-model="showModal" :closable="props.closable" @modal-closed="exit">
|
<modal v-model="showModal" :closable="props.closable">
|
||||||
<div class="error-message" v-if="$route.name == '404'">
|
<div class="error-message" v-if="$route.name == '404' || $route.name == 'notFound'">
|
||||||
<p class="error-404"></p>
|
<p class="error-404"></p>
|
||||||
<p>{{ $t('errors.resource_not_found') }}</p>
|
<p>{{ $t('errors.resource_not_found') }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user