Skip to content

Commit 6005def

Browse files
committed
Merge branch 'feature/vuejs' into feature/dusk-vuejs
2 parents 92c03d4 + dec969b commit 6005def

File tree

6 files changed

+26
-3
lines changed

6 files changed

+26
-3
lines changed

resources/assets/scripts/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const router = new VueRouter({
3535
routes: [
3636
{ name: 'login', path: '/auth/login', component: Login },
3737
{ name: 'forgot-password', path: '/auth/password', component: Login },
38-
{ name: 'checkpoint', path: '/checkpoint', component: Login },
38+
{ name: 'checkpoint', path: '/auth/checkpoint', component: Login },
3939
{
4040
name: 'reset-password',
4141
path: '/auth/password/reset/:token',

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
@@ -70,6 +70,10 @@
7070
email: this.$props.email,
7171
})
7272
.then(function (response) {
73+
if (!(response.data instanceof Object)) {
74+
throw new Error('An error was encountered while processing this request.');
75+
}
76+
7377
self.$data.submitDisabled = false;
7478
self.$data.showSpinner = false;
7579
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
@@ -82,6 +82,12 @@
8282
password: this.$props.user.password,
8383
})
8484
.then(function (response) {
85+
// If there is a 302 redirect or some other odd behavior (basically, response that isnt
86+
// in JSON format) throw an error and don't try to continue with the login.
87+
if (!(response.data instanceof Object)) {
88+
throw new Error('An error was encountered while processing this request.');
89+
}
90+
8591
if (response.data.complete) {
8692
return window.location = '/';
8793
}
@@ -93,6 +99,8 @@
9399
.catch(function (err) {
94100
self.$props.user.password = '';
95101
self.$data.showSpinner = false;
102+
self.$refs.password.focus();
103+
96104
if (!err.response) {
97105
return console.error(err);
98106
}
@@ -102,7 +110,6 @@
102110
response.data.errors.forEach(function (error) {
103111
self.error(error.detail);
104112
});
105-
self.$refs.password.focus();
106113
}
107114
});
108115
},

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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
};
3838
},
3939
mounted: function () {
40+
if ((this.$route.query.token || '').length < 1) {
41+
return this.$router.push({ name: 'login' });
42+
}
43+
4044
this.$refs.code.focus();
4145
},
4246
methods: {
@@ -49,6 +53,10 @@
4953
authentication_code: this.$data.code,
5054
})
5155
.then(function (response) {
56+
if (!(response.data instanceof Object)) {
57+
throw new Error('An error was encountered while processing this login.');
58+
}
59+
5260
window.location = response.data.intended;
5361
})
5462
.catch(function (err) {

0 commit comments

Comments
 (0)