Skip to content

Commit

Permalink
error fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
et-nik committed Jun 1, 2024
1 parent a8a3806 commit fed6d7f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
9 changes: 3 additions & 6 deletions resources/assets/js/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,12 @@ const onAnyStoreAction = ({
onError, // hook if the action throws or rejects
}) => {
onError((error) => {
if (error.response && error.response.status) {
console.log(error.response)
console.log(error.response.status)
switch (error.response.status) {
case 401:
authStore.logout()
router.push({name: 'login'})
authStore.logout().then(() => {
window.location.href = '/'
})
break
case 403:
router.push({name: 'error403'})
Expand Down
12 changes: 12 additions & 0 deletions resources/assets/js/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ window.axios = axios

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'

axios.interceptors.response.use(undefined, function (error) {
if (error.response && error.response.status) {
switch (error.response.status) {
case 401:
window.location.href = '/'
break
}
}

return Promise.reject(error);
})

/**
* Next we will register the CSRF Token as a common header with Axios so that
* all outgoing HTTP requests automatically have it attached. This is just
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/views/errors/Error403View.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<GBreadcrumbs :items="breadcrumbs"></GBreadcrumbs>

<section class="bg-white dark:bg-stone-900">
<section>
<div class="py-8 px-4 mx-auto max-w-screen-xl lg:py-16 lg:px-6">
<div class="mx-auto max-w-screen-sm text-center">
<h1 class="mb-4 text-7xl tracking-tight font-extrabold lg:text-9xl text-stone-600 dark:text-stone-500">403</h1>
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/views/errors/Error404View.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<GBreadcrumbs :items="breadcrumbs"></GBreadcrumbs>

<section class="bg-white dark:bg-stone-900">
<section>
<div class="py-8 px-4 mx-auto max-w-screen-xl lg:py-16 lg:px-6">
<div class="mx-auto max-w-screen-sm text-center">
<h1 class="mb-4 text-7xl tracking-tight font-extrabold lg:text-9xl text-stone-600 dark:text-stone-500">404</h1>
Expand Down

0 comments on commit fed6d7f

Please sign in to comment.