Merge branch 'feature/vuejs' into feature/dusk-vuejs
This commit is contained in:
commit
6005def7bc
6 changed files with 26 additions and 3 deletions
|
@ -35,7 +35,7 @@ const router = new VueRouter({
|
||||||
routes: [
|
routes: [
|
||||||
{ name: 'login', path: '/auth/login', component: Login },
|
{ name: 'login', path: '/auth/login', component: Login },
|
||||||
{ name: 'forgot-password', path: '/auth/password', component: Login },
|
{ name: 'forgot-password', path: '/auth/password', component: Login },
|
||||||
{ name: 'checkpoint', path: '/checkpoint', component: Login },
|
{ name: 'checkpoint', path: '/auth/checkpoint', component: Login },
|
||||||
{
|
{
|
||||||
name: 'reset-password',
|
name: 'reset-password',
|
||||||
path: '/auth/password/reset/:token',
|
path: '/auth/password/reset/:token',
|
||||||
|
|
2
resources/assets/scripts/bootstrap.js
vendored
2
resources/assets/scripts/bootstrap.js
vendored
|
@ -17,8 +17,8 @@ try {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
window.axios = require('axios');
|
window.axios = require('axios');
|
||||||
|
|
||||||
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
||||||
|
window.axios.defaults.headers.common['Accept'] = 'application/json';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Next we will register the CSRF Token as a common header with Axios so that
|
* Next we will register the CSRF Token as a common header with Axios so that
|
||||||
|
|
|
@ -70,6 +70,10 @@
|
||||||
email: this.$props.email,
|
email: this.$props.email,
|
||||||
})
|
})
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
|
if (!(response.data instanceof Object)) {
|
||||||
|
throw new Error('An error was encountered while processing this request.');
|
||||||
|
}
|
||||||
|
|
||||||
self.$data.submitDisabled = false;
|
self.$data.submitDisabled = false;
|
||||||
self.$data.showSpinner = false;
|
self.$data.showSpinner = false;
|
||||||
self.success(response.data.status);
|
self.success(response.data.status);
|
||||||
|
|
|
@ -82,6 +82,12 @@
|
||||||
password: this.$props.user.password,
|
password: this.$props.user.password,
|
||||||
})
|
})
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
|
// If there is a 302 redirect or some other odd behavior (basically, response that isnt
|
||||||
|
// in JSON format) throw an error and don't try to continue with the login.
|
||||||
|
if (!(response.data instanceof Object)) {
|
||||||
|
throw new Error('An error was encountered while processing this request.');
|
||||||
|
}
|
||||||
|
|
||||||
if (response.data.complete) {
|
if (response.data.complete) {
|
||||||
return window.location = '/';
|
return window.location = '/';
|
||||||
}
|
}
|
||||||
|
@ -93,6 +99,8 @@
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
self.$props.user.password = '';
|
self.$props.user.password = '';
|
||||||
self.$data.showSpinner = false;
|
self.$data.showSpinner = false;
|
||||||
|
self.$refs.password.focus();
|
||||||
|
|
||||||
if (!err.response) {
|
if (!err.response) {
|
||||||
return console.error(err);
|
return console.error(err);
|
||||||
}
|
}
|
||||||
|
@ -102,7 +110,6 @@
|
||||||
response.data.errors.forEach(function (error) {
|
response.data.errors.forEach(function (error) {
|
||||||
self.error(error.detail);
|
self.error(error.detail);
|
||||||
});
|
});
|
||||||
self.$refs.password.focus();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -93,6 +93,10 @@
|
||||||
token: this.$props.token,
|
token: this.$props.token,
|
||||||
})
|
})
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
|
if (!(response.data instanceof Object)) {
|
||||||
|
throw new Error('An error was encountered while processing this login.');
|
||||||
|
}
|
||||||
|
|
||||||
return window.location = response.data.redirect_to;
|
return window.location = response.data.redirect_to;
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
|
|
|
@ -37,6 +37,10 @@
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
|
if ((this.$route.query.token || '').length < 1) {
|
||||||
|
return this.$router.push({ name: 'login' });
|
||||||
|
}
|
||||||
|
|
||||||
this.$refs.code.focus();
|
this.$refs.code.focus();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -49,6 +53,10 @@
|
||||||
authentication_code: this.$data.code,
|
authentication_code: this.$data.code,
|
||||||
})
|
})
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
|
if (!(response.data instanceof Object)) {
|
||||||
|
throw new Error('An error was encountered while processing this login.');
|
||||||
|
}
|
||||||
|
|
||||||
window.location = response.data.intended;
|
window.location = response.data.intended;
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
|
|
Loading…
Reference in a new issue