Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc976f96

Browse files
committed
Fixed authentication with file manager.
1 parent9396aad commitc976f96

File tree

11 files changed

+70
-137
lines changed

11 files changed

+70
-137
lines changed

‎package-lock.json

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎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.80",
3+
"version":"3.0.159",
44
"description":"File manager for Laravel",
55
"keywords": [
66
"laravel",

‎src/FileManager.vue

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,27 @@ export default {
8585
};
8686
},
8787
created() {
88-
// manual settings
89-
this.$store.commit('fm/settings/manualSettings',this.settings);
90-
// initiate Axios
91-
this.$store.commit('fm/settings/initAxiosSettings');
92-
this.setAxiosConfig();
93-
this.requestInterceptor();
94-
this.responseInterceptor();
95-
96-
// initialize app settings
97-
// Mohammad Ashrafuddin Ferdousi : 1
98-
// Mohammad Ashrafuddin Ferdousi : 2
99-
this.$store.dispatch('fm/initializeApp');
88+
newPromise(resolve=> {
89+
// manual settings
90+
this.$store.commit('fm/settings/manualSettings',this.settings);
91+
resolve();
92+
}).then(()=> {
93+
// initiate Axios
94+
this.$store.commit('fm/settings/initAxiosSettings');
95+
}).then(()=> {
96+
this.setAxiosConfig();
97+
}).then(()=> {
98+
this.requestInterceptor();
99+
}).then(()=> {
100+
this.responseInterceptor();
101+
}).then(()=> {
102+
// initialize app settings
103+
// Mohammad Ashrafuddin Ferdousi : 1
104+
// Mohammad Ashrafuddin Ferdousi : 2
105+
this.$store.dispatch('fm/initializeApp');
106+
}).catch(err=> {
107+
Promise.reject(err);
108+
});
100109
},
101110
destroyed() {
102111
// reset state
@@ -118,44 +127,19 @@ export default {
118127
}),
119128
},
120129
methods: {
121-
storeAxiosConfig() {
122-
localstore.setStorage(localstore.axiosSettingType,this.settings);
123-
},
124130
/**
125131
* Axios default config
126132
*/
127-
setAxiosConfig() {
128-
/** Original version **/
129-
/*HTTP.defaults.baseURL = this.$store.getters['fm/settings/baseUrl'];
130-
HTTP.defaults.headers = this.$store.getters['fm/settings/headers'];*/
131-
132-
/** Customized by Mohammad Ashrafuddin Ferdousi*/
133-
// Uncomment when needed.
134-
/*let settings = localstore.getStorage(localstore.axiosSettingType);
135-
136-
if(settings) {
137-
HTTP.interceptors.request.use(config => {
138-
config.baseURL = settings.baseURL;
139-
config.withCredentials = settings.withCredentials;
140-
config.headers = settings.headers;
141-
config.headers.common.Authorization = `Bearer ${window.localStorage.getItem('_token')}`;
142-
143-
return config;
144-
}, error => Promise.reject(error)
145-
);
146-
} else {
147-
throw `settings.baseURL: ${settings.baseURL}, settings.withCredentials: ${settings.withCredentials}, settings.headers: ${settings.headers} is set!`;
148-
}*/
149-
// End of uncomment when needed.
150-
HTTP.interceptors.request.use(config=> {
151-
config.baseURL=this.$store.getters['fm/settings/baseUrl'];
152-
config.withCredentials=this.$store.getters['fm/settings/withCredentials'];
153-
config.headers=this.$store.getters['fm/settings/headers'];
154-
config.headers.common.Authorization=`Bearer${window.localStorage.getItem('_token')}`;
155-
156-
return config;
157-
},error=>Promise.reject(error)
158-
);
133+
asyncsetAxiosConfig() {
134+
HTTP.defaults.baseURL=this.$store.getters['fm/settings/baseUrl'];
135+
HTTP.defaults.withCredentials=this.$store.getters['fm/settings/withCredentials'];
136+
HTTP.defaults.headers=this.$store.getters['fm/settings/headers'];
137+
HTTP.defaults.headers.common= {};
138+
HTTP.defaults.headers.common['X-Requested-With']='XMLHttpRequest';
139+
let token=awaitnewPromise(resolve=> {
140+
resolve(window.localStorage.getItem('_token'));
141+
});
142+
HTTP.defaults.headers.Authorization=`Bearer${token}`;
159143
},
160144
161145
/**

‎src/components/manager/Thumbnail.vue

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
<template>
2-
<figureclass="fm-thumbnail">
2+
<!--<figure>
33
<transition name="fade" mode="out-in">
44
<i v-if="!src" class="far fa-file-image fa-5x pb-2" />
55
<img v-else v-bind:src="src" v-bind:alt="file.filename" class="img-thumbnail" />
66
</transition>
7-
</figure>
7+
</figure>-->
8+
<divclass="fm-thumbnail">
9+
<transitionname="fade"mode="out-in">
10+
<divclass="spinner-border spinner-border-lg text-muted my-2"v-if="!src">
11+
<spanclass="visually-hidden">Loading...</span>
12+
</div>
13+
<imgv-elsev-bind:src="src"v-bind:alt="file.filename"class="img-thumbnail" />
14+
</transition>
15+
</div>
816
</template>
917

1018
<script>
@@ -31,7 +39,7 @@ export default {
3139
'file.timestamp':'loadImage',
3240
},
3341
mounted() {
34-
if (window.IntersectionObserver) {
42+
/*if (window.IntersectionObserver) {
3543
const observer = new IntersectionObserver(
3644
(entries, obs) => {
3745
entries.forEach((entry) => {
@@ -51,7 +59,8 @@ export default {
5159
observer.observe(this.$el);
5260
} else {
5361
this.loadImage();
54-
}
62+
}*/
63+
this.loadImage();
5564
},
5665
computed: {
5766
/**
@@ -71,16 +80,19 @@ export default {
7180
// if authorization required
7281
if (this.auth) {
7382
// Mohammad Ashrafuddin Ferdousi : 8
74-
GET.thumbnail(this.disk,`${this.file.path}&token=${window.localStorage.getItem('_token')}`).then((response)=> {
83+
GET.thumbnail(this.disk,this.file.path).then((response)=> {
7584
// FIXED: Mohammad Ashrafuddin Ferdousi
7685
constmimeType=response.data.headers['Content-Type'].toLowerCase();
7786
//const imgBase64 = Buffer.from(response.data, 'binary').toString('base64');
7887
this.src=`data:${mimeType};base64,${response.data.data}`;
7988
});
89+
/*this.src = `${this.$store.getters['fm/settings/baseUrl']}thumbnails?disk=${
90+
this.disk
91+
}&path=${encodeURIComponent(this.file.path)}&v=${this.file.timestamp}&token=${window.localStorage.getItem('_token')}`;*/
8092
}else {
8193
this.src=`${this.$store.getters['fm/settings/baseUrl']}thumbnails?disk=${
8294
this.disk
83-
}&path=${encodeURIComponent(this.file.path)}&v=${this.file.timestamp}&token=${window.localStorage.getItem('_token')}`;
95+
}&path=${encodeURIComponent(this.file.path)}&v=${this.file.timestamp}`;
8496
}
8597
},
8698
},

‎src/components/modals/views/PreviewModal.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,16 @@ export default {
132132
// if authorization required
133133
if (this.auth) {
134134
// Mohammad Ashrafuddin Ferdousi : 9
135-
GET.preview(this.selectedDisk,`${this.selectedItem.path}&token=${window.localStorage.getItem('_token')}`).then((response)=> {
135+
GET.preview(this.selectedDisk,this.selectedItem.path).then((response)=> {
136136
// FIXED: Mohammad Ashrafuddin Ferdousi
137137
constmimeType=response.data.headers['Content-Type'].toLowerCase();
138-
// const imgBase64 = Buffer.from(response.data, 'binary').toString('base64');
139-
138+
//const imgBase64 = Buffer.from(response.data, 'binary').toString('base64');
140139
this.imgSrc=`data:${mimeType};base64,${response.data.data}`;
141140
});
142141
}else {
143142
this.imgSrc=`${this.$store.getters['fm/settings/baseUrl']}preview?disk=${
144143
this.selectedDisk
145-
}&path=${encodeURIComponent(this.selectedItem.path)}&v=${this.selectedItem.timestamp}&token=${window.localStorage.getItem('_token')}`;
144+
}&path=${encodeURIComponent(this.selectedItem.path)}&v=${this.selectedItem.timestamp}`;
146145
}
147146
},
148147
},

‎src/http/axios.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
11
importaxiosfrom'axios';
2-
// Uncomment when needed.
3-
/*import localstore from '../mixins/localstore';
4-
5-
let settings = localstore.getStorage(localstore.axiosSettingType);
6-
7-
if(settings) {
8-
if(settings.baseURL) axios.defaults.baseURL = settings.baseURL;
9-
if(settings.withCredentials) axios.defaults.withCredentials = settings.withCredentials;
10-
if(settings.headers) axios.defaults.headers = settings.headers;
11-
}
12-
13-
// set new axios instance
14-
export default axios.create(settings);*/
15-
// End of uncomment when needed.
162

173
exportdefaultaxios.create();

‎src/http/get.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import HTTP from './axios';
22

33
exportdefault{
44
asyncgetToken(){
5-
returnnewPromise(resolve=>{
6-
resolve(window.localStorage.getItem('_token'));
7-
});
5+
returnwindow.localStorage.getItem('_token');
86
},
97
/**
108
* Get configuration data from server
@@ -13,7 +11,9 @@ export default {
1311
// Mohammad Ashrafuddin Ferdousi : 1
1412
asyncinitialize(){
1513
lettoken=awaitthis.getToken();
16-
returnHTTP.get(`initialize?token=${token}`);
14+
HTTP.defaults.headers.Authorization=`Bearer${token}`;
15+
16+
returnHTTP.get('initialize');
1717
},
1818

1919
/**
@@ -101,7 +101,7 @@ export default {
101101
// Mohammad Ashrafuddin Ferdousi : 8
102102
thumbnail(disk,path){
103103
returnHTTP.get('thumbnails',{
104-
responseType:'arraybuffer',
104+
responseType:'json',
105105
params:{ disk, path},
106106
});
107107
},
@@ -115,7 +115,7 @@ export default {
115115
// Mohammad Ashrafuddin Ferdousi : 9
116116
preview(disk,path){
117117
returnHTTP.get('preview',{
118-
responseType:'arraybuffer',
118+
responseType:'json',
119119
params:{ disk, path},
120120
});
121121
},

‎src/store/actions.js

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ export default {
1515
// Mohammad Ashrafuddin Ferdousi : 2
1616
initializeApp({ state, commit, getters, dispatch}){
1717
// Mohammad Ashrafuddin Ferdousi : 1
18-
letinit=GET.initialize();
19-
init.then((response)=>{
18+
GET.initialize().then((response)=>{
2019
if(response.data.result.status==='success'){
2120
commit('settings/initSettings',response.data.config);
2221
commit('setDisks',response.data.config.disks);
@@ -91,37 +90,6 @@ export default {
9190
});
9291
}
9392
}
94-
else{
95-
if(getters.callInitTill){
96-
setTimeout(()=>{
97-
window.location.reload();
98-
commit('increaseInitCallCount');
99-
},1000);
100-
}
101-
// Uncomment when needed.
102-
/*if(getters.callInitTill) {
103-
setTimeout(() => {
104-
dispatch('initializeApp');
105-
commit('increaseInitCallCount');
106-
}, 1000);
107-
}*/
108-
// End of uncomment when needed.
109-
}
110-
}).catch(err=>{
111-
if(getters.callInitTill){
112-
setTimeout(()=>{
113-
window.location.reload();
114-
commit('increaseInitCallCount');
115-
},1000);
116-
}
117-
// Uncomment when needed.
118-
/*if(getters.callInitTill) {
119-
setTimeout(() => {
120-
dispatch('initializeApp');
121-
commit('increaseInitCallCount');
122-
}, 1000);
123-
}*/
124-
// End of uncomment when needed.
12593
});
12694
},
12795

‎src/store/getters.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,4 @@ export default {
4444
inactiveManager(state){
4545
returnstate.activeManager==='left' ?'right' :'left';
4646
},
47-
48-
/**
49-
*
50-
*@param state
51-
*@returns {boolean}
52-
*/
53-
callInitTill(state){
54-
returnstate.initCallCount<2;
55-
}
5647
};

‎src/store/mutations.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,4 @@ export default {
9292
state.fileCallback=null;
9393
state.fullScreen=false;
9494
},
95-
96-
increaseInitCallCount(state){
97-
state.initCallCount++;
98-
}
9995
};

‎src/store/state.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,4 @@ export default {
2525

2626
// full screen mode
2727
fullScreen:false,
28-
29-
//initializeApp call count
30-
initCallCount:0,
3128
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp