Skip to content

Commit 225a0f8

Browse files
committed
Add upload password query string psi-4ward#322
1 parent e017ff4 commit 225a0f8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

app/src/Upload/store/config.js

+19
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@ export default {
2222
return new Promise((resolve, reject) => {
2323
const xhr = new XMLHttpRequest();
2424
xhr.open('GET', 'config.json');
25+
26+
// Allow using query string to set upload pass
27+
const params = new URLSearchParams(window.location.search);
28+
const querystringUploadPass = params.get("upload_key");
29+
30+
if (querystringUploadPass) {
31+
state.uploadPass = querystringUploadPass;
32+
params.delete("upload_key"); // Remove the parameter
33+
34+
// Build the new URL
35+
const newUrl =
36+
params.toString().length > 0
37+
? window.location.pathname + "?" + params.toString()
38+
: window.location.pathname; // Remove "?" if no other params exist
39+
40+
// Update the URL without reloading
41+
window.history.replaceState(null, "", newUrl);
42+
}
43+
2544
state.uploadPass && xhr.setRequestHeader('x-passwd', state.uploadPass);
2645
xhr.onload = () => {
2746
if(xhr.status === 200) {

0 commit comments

Comments
 (0)