mirror of
https://github.com/onionshare/onionshare.git
synced 2025-06-22 13:34:23 -04:00
Update ReceiveMode to no longer rely on slugs
This commit is contained in:
parent
3ab99dbf3b
commit
403125f844
3 changed files with 7 additions and 27 deletions
|
@ -34,15 +34,7 @@ class ReceiveModeWeb(object):
|
||||||
@self.web.app.route("/")
|
@self.web.app.route("/")
|
||||||
def index():
|
def index():
|
||||||
self.web.add_request(self.web.REQUEST_LOAD, request.path)
|
self.web.add_request(self.web.REQUEST_LOAD, request.path)
|
||||||
|
r = make_response(render_template('receive.html'))
|
||||||
if self.common.settings.get('public_mode'):
|
|
||||||
upload_action = '/upload'
|
|
||||||
else:
|
|
||||||
upload_action = '/{}/upload'.format(self.web.password)
|
|
||||||
|
|
||||||
r = make_response(render_template(
|
|
||||||
'receive.html',
|
|
||||||
upload_action=upload_action))
|
|
||||||
return self.web.add_security_headers(r)
|
return self.web.add_security_headers(r)
|
||||||
|
|
||||||
@self.web.app.route("/upload", methods=['POST'])
|
@self.web.app.route("/upload", methods=['POST'])
|
||||||
|
@ -83,11 +75,7 @@ class ReceiveModeWeb(object):
|
||||||
return json.dumps({"error_flashes": [msg]})
|
return json.dumps({"error_flashes": [msg]})
|
||||||
else:
|
else:
|
||||||
flash(msg, 'error')
|
flash(msg, 'error')
|
||||||
|
return redirect('/')
|
||||||
if self.common.settings.get('public_mode'):
|
|
||||||
return redirect('/')
|
|
||||||
else:
|
|
||||||
return redirect('/{}'.format(password_candidate))
|
|
||||||
|
|
||||||
# Note that flash strings are in English, and not translated, on purpose,
|
# Note that flash strings are in English, and not translated, on purpose,
|
||||||
# to avoid leaking the locale of the OnionShare user
|
# to avoid leaking the locale of the OnionShare user
|
||||||
|
@ -114,11 +102,7 @@ class ReceiveModeWeb(object):
|
||||||
if ajax:
|
if ajax:
|
||||||
return json.dumps({"info_flashes": info_flashes})
|
return json.dumps({"info_flashes": info_flashes})
|
||||||
else:
|
else:
|
||||||
if self.common.settings.get('public_mode'):
|
return redirect('/')
|
||||||
path = '/'
|
|
||||||
else:
|
|
||||||
path = '/{}'.format(password_candidate)
|
|
||||||
return redirect('{}'.format(path))
|
|
||||||
else:
|
else:
|
||||||
if ajax:
|
if ajax:
|
||||||
return json.dumps({"new_body": render_template('thankyou.html')})
|
return json.dumps({"new_body": render_template('thankyou.html')})
|
||||||
|
@ -234,12 +218,8 @@ class ReceiveModeRequest(Request):
|
||||||
# Is this a valid upload request?
|
# Is this a valid upload request?
|
||||||
self.upload_request = False
|
self.upload_request = False
|
||||||
if self.method == 'POST':
|
if self.method == 'POST':
|
||||||
if self.web.common.settings.get('public_mode'):
|
if self.path == '/upload' or self.path == '/upload-ajax':
|
||||||
if self.path == '/upload' or self.path == '/upload-ajax':
|
self.upload_request = True
|
||||||
self.upload_request = True
|
|
||||||
else:
|
|
||||||
if self.path == '/{}/upload'.format(self.web.password) or self.path == '/{}/upload-ajax'.format(self.web.password):
|
|
||||||
self.upload_request = True
|
|
||||||
|
|
||||||
if self.upload_request:
|
if self.upload_request:
|
||||||
# No errors yet
|
# No errors yet
|
||||||
|
|
|
@ -121,7 +121,7 @@ $(function(){
|
||||||
$('#uploads').append($upload_div);
|
$('#uploads').append($upload_div);
|
||||||
|
|
||||||
// Send the request
|
// Send the request
|
||||||
ajax.open('POST', window.location.pathname.replace(/\/$/, '') + '/upload-ajax', true);
|
ajax.open('POST', '/upload-ajax', true);
|
||||||
ajax.send(formData);
|
ajax.send(formData);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form id="send" method="post" enctype="multipart/form-data" action="{{ upload_action }}">
|
<form id="send" method="post" enctype="multipart/form-data" action="/upload">
|
||||||
<p><input type="file" id="file-select" name="file[]" multiple /></p>
|
<p><input type="file" id="file-select" name="file[]" multiple /></p>
|
||||||
<p><button type="submit" id="send-button" class="button">Send Files</button></p>
|
<p><button type="submit" id="send-button" class="button">Send Files</button></p>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue