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';
|
||||
|
||||
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
|
||||
* for events that are broadcast by Laravel. Echo and event broadcasting
|
||||
|
||||
@ -48,14 +48,10 @@ export default {
|
||||
});
|
||||
},
|
||||
getCurrentToken() {
|
||||
if (!!axios.defaults.headers.common.Authorization) {
|
||||
return axios.defaults.headers.common.Authorization;
|
||||
}
|
||||
const tokenData = JSON.parse(window.localStorage.getItem('authentication-token'));
|
||||
|
||||
if (window.localStorage.getItem('authentication-token')) {
|
||||
const tokenData = JSON.parse(window.localStorage.getItem('authentication-token'));
|
||||
|
||||
if (moment(tokenData.valid_until) > moment()) {
|
||||
if (!!tokenData) {
|
||||
if (new Date(tokenData.valid_until) > new Date()) {
|
||||
this.tokenId = tokenData.id;
|
||||
axios.defaults.headers.common.Authorization = tokenData.token;
|
||||
return tokenData.token;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user