Skip to content

Commit e989bf2

Browse files
committed
Refresh on unauthorized response.
1 parent bcf5e9d commit e989bf2

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "laravel-frontend-file-manager",
3-
"version": "3.0.53",
3+
"version": "3.0.68",
44
"description": "File manager for Laravel",
55
"keywords": [
66
"laravel",

src/FileManager.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,11 @@ export default {
133133
let settings = localstore.getStorage(localstore.axiosSettingType);
134134
135135
if(settings) {
136-
HTTP.interceptors.request.use( async config => {
136+
HTTP.interceptors.request.use(config => {
137137
config.baseURL = settings.baseURL;
138138
config.withCredentials = settings.withCredentials;
139139
config.headers = settings.headers;
140+
config.headers.common.Authorization = `Bearer ${window.localStorage.getItem('_token')}`;
140141
141142
return config;
142143
}, error => Promise.reject(error)

src/http/get.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import HTTP from './axios';
22

33
export default {
4+
async getToken() {
5+
return new Promise(resolve => {
6+
resolve(window.localStorage.getItem('_token'));
7+
});
8+
},
49
/**
510
* Get configuration data from server
611
* @returns {*}
712
*/
813
// Mohammad Ashrafuddin Ferdousi : 1
9-
initialize() {
10-
return HTTP.get(`initialize?token=${window.localStorage.getItem('_token')}`);
14+
async initialize() {
15+
let token = await this.getToken();
16+
return HTTP.get(`initialize?token=${token}`);
1117
},
1218

1319
/**

src/store/actions.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ export default {
8989
}
9090
});
9191
}
92+
} else {
93+
window.location.reload();
9294
}
95+
}).catch(err => {
96+
window.location.reload();
9397
});
9498
},
9599

0 commit comments

Comments
 (0)