mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-28 00:39:37 -05:00
Make the receive.html template not use slugs if receive_public_mode is True, and fix some bugs with receive routes
This commit is contained in:
parent
8939d279e3
commit
9857d9fce8
@ -288,9 +288,17 @@ class Web(object):
|
||||
def index_logic():
|
||||
self.add_request(Web.REQUEST_LOAD, request.path)
|
||||
|
||||
if self.common.settings.get('receive_public_mode'):
|
||||
upload_action = '/upload'
|
||||
close_action = '/close'
|
||||
else:
|
||||
upload_action = '/{}/upload'.format(self.slug)
|
||||
close_action = '/{}/close'.format(self.slug)
|
||||
|
||||
r = make_response(render_template(
|
||||
'receive.html',
|
||||
slug=self.slug,
|
||||
upload_action=upload_action,
|
||||
close_action=close_action,
|
||||
receive_allow_receiver_shutdown=self.common.settings.get('receive_allow_receiver_shutdown')))
|
||||
return self.add_security_headers(r)
|
||||
|
||||
@ -324,7 +332,10 @@ class Web(object):
|
||||
valid = False
|
||||
if not valid:
|
||||
flash('Error uploading, please inform the OnionShare user')
|
||||
return redirect('/{}'.format(slug_candidate))
|
||||
if self.common.settings.get('receive_public_mode'):
|
||||
return redirect('/')
|
||||
else:
|
||||
return redirect('/{}'.format(slug_candidate))
|
||||
|
||||
files = request.files.getlist('file[]')
|
||||
filenames = []
|
||||
@ -383,14 +394,17 @@ class Web(object):
|
||||
for filename in filenames:
|
||||
flash('Uploaded {}'.format(filename))
|
||||
|
||||
return redirect('/{}'.format(slug_candidate))
|
||||
if self.common.settings.get('receive_public_mode'):
|
||||
return redirect('/')
|
||||
else:
|
||||
return redirect('/{}'.format(slug_candidate))
|
||||
|
||||
@self.app.route("/<slug_candidate>/upload", methods=['POST'])
|
||||
def upload(slug_candidate):
|
||||
self.check_slug_candidate(slug_candidate)
|
||||
return upload_logic(slug_candidate)
|
||||
|
||||
@self.app.route("/upload")
|
||||
@self.app.route("/upload", methods=['POST'])
|
||||
def upload_public():
|
||||
if not self.common.settings.get('receive_public_mode'):
|
||||
return self.error404()
|
||||
@ -411,7 +425,7 @@ class Web(object):
|
||||
self.check_slug_candidate(slug_candidate)
|
||||
return close_logic(slug_candidate)
|
||||
|
||||
@self.app.route("/upload")
|
||||
@self.app.route("/close", methods=['POST'])
|
||||
def close_public():
|
||||
if not self.common.settings.get('receive_public_mode'):
|
||||
return self.error404()
|
||||
|
@ -17,7 +17,7 @@
|
||||
<p><img class="logo" src="/static/img/logo_large.png" title="OnionShare"></p>
|
||||
<p class="upload-header">Send Files</p>
|
||||
<p class="upload-description">Select the files you want to send, then click "Send Files"...</p>
|
||||
<form method="post" enctype="multipart/form-data" action="/{{ slug }}/upload">
|
||||
<form method="post" enctype="multipart/form-data" action="{{ upload_action }}">
|
||||
<p><input type="file" name="file[]" multiple /></p>
|
||||
<p><input type="submit" class="button" value="Send Files" /></p>
|
||||
<div>
|
||||
@ -35,7 +35,7 @@
|
||||
</div>
|
||||
</div>
|
||||
{% if receive_allow_receiver_shutdown %}
|
||||
<form method="post" action="/{{ slug }}/close">
|
||||
<form method="post" action="{{ close_action }}">
|
||||
<input type="submit" class="close-button" value="I'm Finished Uploading" />
|
||||
</form>
|
||||
{% endif %}
|
||||
|
Loading…
Reference in New Issue
Block a user