Check for public_mode in the check_slug_candidate function, to make 404 errors work again during public mode

This commit is contained in:
Micah Lee 2018-09-15 19:47:42 -07:00
parent 8bb75cc530
commit 9815c612eb
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73

View File

@ -143,8 +143,7 @@ class Web(object):
"""
@self.app.route("/<slug_candidate>")
def index(slug_candidate):
if not self.common.settings.get('public_mode'):
self.check_slug_candidate(slug_candidate)
self.check_slug_candidate(slug_candidate)
return index_logic()
@self.app.route("/")
@ -187,8 +186,7 @@ class Web(object):
@self.app.route("/<slug_candidate>/download")
def download(slug_candidate):
if not self.common.settings.get('public_mode'):
self.check_slug_candidate(slug_candidate)
self.check_slug_candidate(slug_candidate)
return download_logic()
@self.app.route("/download")
@ -331,8 +329,7 @@ class Web(object):
@self.app.route("/<slug_candidate>")
def index(slug_candidate):
if not self.common.settings.get('public_mode'):
self.check_slug_candidate(slug_candidate)
self.check_slug_candidate(slug_candidate)
return index_logic()
@self.app.route("/")
@ -430,8 +427,7 @@ class Web(object):
@self.app.route("/<slug_candidate>/upload", methods=['POST'])
def upload(slug_candidate):
if not self.common.settings.get('public_mode'):
self.check_slug_candidate(slug_candidate)
self.check_slug_candidate(slug_candidate)
return upload_logic(slug_candidate)
@self.app.route("/upload", methods=['POST'])
@ -452,8 +448,7 @@ class Web(object):
@self.app.route("/<slug_candidate>/close", methods=['POST'])
def close(slug_candidate):
if not self.common.settings.get('public_mode'):
self.check_slug_candidate(slug_candidate)
self.check_slug_candidate(slug_candidate)
return close_logic(slug_candidate)
@self.app.route("/close", methods=['POST'])
@ -574,10 +569,14 @@ class Web(object):
self.app.logger.addHandler(log_handler)
def check_slug_candidate(self, slug_candidate, slug_compare=None):
if not slug_compare:
slug_compare = self.slug
if not hmac.compare_digest(slug_compare, slug_candidate):
self.common.log('Web', 'check_slug_candidate: slug_candidate={}, slug_compare={}'.format(slug_candidate, slug_compare))
if self.common.settings.get('public_mode'):
abort(404)
else:
if not slug_compare:
slug_compare = self.slug
if not hmac.compare_digest(slug_compare, slug_candidate):
abort(404)
def force_shutdown(self):
"""