Refactor login page to work on all parts
This commit is contained in:
parent
77deb525df
commit
2d5eec9dfe
8
resources/js/bootstrap.js
vendored
8
resources/js/bootstrap.js
vendored
@ -11,6 +11,14 @@ window.axios = require('axios');
|
|||||||
|
|
||||||
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
||||||
|
|
||||||
|
const tokenData = JSON.parse(window.localStorage.getItem('authentication-token'));
|
||||||
|
|
||||||
|
if (!!tokenData) {
|
||||||
|
if (new Date(tokenData.valid_until) > new Date()) {
|
||||||
|
axios.defaults.headers.common.Authorization = tokenData.token;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Echo exposes an expressive API for subscribing to channels and listening
|
* Echo exposes an expressive API for subscribing to channels and listening
|
||||||
* for events that are broadcast by Laravel. Echo and event broadcasting
|
* for events that are broadcast by Laravel. Echo and event broadcasting
|
||||||
|
|||||||
@ -48,14 +48,10 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
getCurrentToken() {
|
getCurrentToken() {
|
||||||
if (!!axios.defaults.headers.common.Authorization) {
|
const tokenData = JSON.parse(window.localStorage.getItem('authentication-token'));
|
||||||
return axios.defaults.headers.common.Authorization;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window.localStorage.getItem('authentication-token')) {
|
if (!!tokenData) {
|
||||||
const tokenData = JSON.parse(window.localStorage.getItem('authentication-token'));
|
if (new Date(tokenData.valid_until) > new Date()) {
|
||||||
|
|
||||||
if (moment(tokenData.valid_until) > moment()) {
|
|
||||||
this.tokenId = tokenData.id;
|
this.tokenId = tokenData.id;
|
||||||
axios.defaults.headers.common.Authorization = tokenData.token;
|
axios.defaults.headers.common.Authorization = tokenData.token;
|
||||||
return tokenData.token;
|
return tokenData.token;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user