Add authentication followup to front-end to ease navigation & redirects

This commit is contained in:
Bubka
2023-08-04 15:13:30 +02:00
parent afd020019b
commit a80a002ce7
5 changed files with 26 additions and 6 deletions

6
resources/js/api.js vendored
View File

@ -13,6 +13,12 @@ if (window.appConfig.subdirectory) {
}
Vue.axios.interceptors.response.use(response => response, error => {
// Whether or not the promise must be returned, if unauthenticated is received
// we update the auth state of the front-end
if ( error.response.status === 401 ) {
Vue.$storage.remove('authenticated')
}
// Return the error when we need to handle it at component level
if( error.config.hasOwnProperty('returnError') && error.config.returnError === true ) {