Skip to content

Commit

Permalink
Handle unauthenticated responses
Browse files Browse the repository at this point in the history
  • Loading branch information
nWidart committed Sep 16, 2017
1 parent 4e6d38c commit 74bc58b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
9 changes: 8 additions & 1 deletion public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31311,13 +31311,20 @@ var app = new _vue2.default({
});

window.axios.interceptors.response.use(null, function (error) {
if (error.response.status === 401) {
if (error.response.status === 403) {
app.$notify.error({
title: app.$t('core.unauthorized'),
message: app.$t('core.unauthorized-access')
});
window.location = route('dashboard.index');
}
if (error.response.status === 401) {
app.$notify.error({
title: app.$t('core.unauthenticated'),
message: app.$t('core.unauthenticated-message')
});
window.location = route('login');
}
return Promise.reject(error);
});

Expand Down
11 changes: 9 additions & 2 deletions resources/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,19 @@ const app = new Vue({
});

window.axios.interceptors.response.use(null, function(error) {
if (error.response.status === 401) {
if (error.response.status === 403) {
app.$notify.error({
title: app.$t('core.unauthorized'),
message: app.$t('core.unauthorized-access'),
});
window.location = route('dashboard.index')
window.location = route('dashboard.index');
}
if (error.response.status === 401) {
app.$notify.error({
title: app.$t('core.unauthenticated'),
message: app.$t('core.unauthenticated-message'),
});
window.location = route('login');
}
return Promise.reject(error);
});

0 comments on commit 74bc58b

Please sign in to comment.