mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-29 09:16:24 -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():
|
def index_logic():
|
||||||
self.add_request(Web.REQUEST_LOAD, request.path)
|
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(
|
r = make_response(render_template(
|
||||||
'receive.html',
|
'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')))
|
receive_allow_receiver_shutdown=self.common.settings.get('receive_allow_receiver_shutdown')))
|
||||||
return self.add_security_headers(r)
|
return self.add_security_headers(r)
|
||||||
|
|
||||||
@ -324,6 +332,9 @@ class Web(object):
|
|||||||
valid = False
|
valid = False
|
||||||
if not valid:
|
if not valid:
|
||||||
flash('Error uploading, please inform the OnionShare user')
|
flash('Error uploading, please inform the OnionShare user')
|
||||||
|
if self.common.settings.get('receive_public_mode'):
|
||||||
|
return redirect('/')
|
||||||
|
else:
|
||||||
return redirect('/{}'.format(slug_candidate))
|
return redirect('/{}'.format(slug_candidate))
|
||||||
|
|
||||||
files = request.files.getlist('file[]')
|
files = request.files.getlist('file[]')
|
||||||
@ -383,6 +394,9 @@ class Web(object):
|
|||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
flash('Uploaded {}'.format(filename))
|
flash('Uploaded {}'.format(filename))
|
||||||
|
|
||||||
|
if self.common.settings.get('receive_public_mode'):
|
||||||
|
return redirect('/')
|
||||||
|
else:
|
||||||
return redirect('/{}'.format(slug_candidate))
|
return redirect('/{}'.format(slug_candidate))
|
||||||
|
|
||||||
@self.app.route("/<slug_candidate>/upload", methods=['POST'])
|
@self.app.route("/<slug_candidate>/upload", methods=['POST'])
|
||||||
@ -390,7 +404,7 @@ class Web(object):
|
|||||||
self.check_slug_candidate(slug_candidate)
|
self.check_slug_candidate(slug_candidate)
|
||||||
return upload_logic(slug_candidate)
|
return upload_logic(slug_candidate)
|
||||||
|
|
||||||
@self.app.route("/upload")
|
@self.app.route("/upload", methods=['POST'])
|
||||||
def upload_public():
|
def upload_public():
|
||||||
if not self.common.settings.get('receive_public_mode'):
|
if not self.common.settings.get('receive_public_mode'):
|
||||||
return self.error404()
|
return self.error404()
|
||||||
@ -411,7 +425,7 @@ class Web(object):
|
|||||||
self.check_slug_candidate(slug_candidate)
|
self.check_slug_candidate(slug_candidate)
|
||||||
return close_logic(slug_candidate)
|
return close_logic(slug_candidate)
|
||||||
|
|
||||||
@self.app.route("/upload")
|
@self.app.route("/close", methods=['POST'])
|
||||||
def close_public():
|
def close_public():
|
||||||
if not self.common.settings.get('receive_public_mode'):
|
if not self.common.settings.get('receive_public_mode'):
|
||||||
return self.error404()
|
return self.error404()
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<p><img class="logo" src="/static/img/logo_large.png" title="OnionShare"></p>
|
<p><img class="logo" src="/static/img/logo_large.png" title="OnionShare"></p>
|
||||||
<p class="upload-header">Send Files</p>
|
<p class="upload-header">Send Files</p>
|
||||||
<p class="upload-description">Select the files you want to send, then click "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="file" name="file[]" multiple /></p>
|
||||||
<p><input type="submit" class="button" value="Send Files" /></p>
|
<p><input type="submit" class="button" value="Send Files" /></p>
|
||||||
<div>
|
<div>
|
||||||
@ -35,7 +35,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if receive_allow_receiver_shutdown %}
|
{% 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" />
|
<input type="submit" class="close-button" value="I'm Finished Uploading" />
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user