Skip to content

Commit 4209be0

Browse files
committed
Add handlers for non-successful responses from the panel
1 parent ebb7b6d commit 4209be0

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

resources/assets/scripts/bootstrap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ try {
1717
*/
1818

1919
window.axios = require('axios');
20-
2120
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
21+
window.axios.defaults.headers.common['Accept'] = 'application/json';
2222

2323
/**
2424
* Next we will register the CSRF Token as a common header with Axios so that

resources/assets/scripts/components/auth/ForgotPassword.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@
6868
email: this.$props.email,
6969
})
7070
.then(function (response) {
71+
if (!(response.data instanceof Object)) {
72+
throw new Error('An error was encountered while processing this request.');
73+
}
74+
7175
self.$data.submitDisabled = false;
7276
self.$data.showSpinner = false;
7377
self.success(response.data.status);

resources/assets/scripts/components/auth/LoginForm.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@
8181
password: this.$props.user.password,
8282
})
8383
.then(function (response) {
84+
// If there is a 302 redirect or some other odd behavior (basically, response that isnt
85+
// in JSON format) throw an error and don't try to continue with the login.
86+
if (!(response.data instanceof Object)) {
87+
throw new Error('An error was encountered while processing this request.');
88+
}
89+
8490
if (response.data.complete) {
8591
return window.location = '/';
8692
}
@@ -92,6 +98,8 @@
9298
.catch(function (err) {
9399
self.$props.user.password = '';
94100
self.$data.showSpinner = false;
101+
self.$refs.password.focus();
102+
95103
if (!err.response) {
96104
return console.error(err);
97105
}
@@ -101,7 +109,6 @@
101109
response.data.errors.forEach(function (error) {
102110
self.error(error.detail);
103111
});
104-
self.$refs.password.focus();
105112
}
106113
});
107114
},

resources/assets/scripts/components/auth/ResetPassword.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@
9393
token: this.$props.token,
9494
})
9595
.then(function (response) {
96+
if (!(response.data instanceof Object)) {
97+
throw new Error('An error was encountered while processing this login.');
98+
}
99+
96100
return window.location = response.data.redirect_to;
97101
})
98102
.catch(function (err) {

resources/assets/scripts/components/auth/TwoFactorForm.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
authentication_code: this.$data.code,
5050
})
5151
.then(function (response) {
52+
if (!(response.data instanceof Object)) {
53+
throw new Error('An error was encountered while processing this login.');
54+
}
55+
5256
window.location = response.data.intended;
5357
})
5458
.catch(function (err) {

0 commit comments

Comments
 (0)