Skip to content

Commit

Permalink
remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
jdabtieu committed Nov 19, 2023
1 parent 0e4a5cf commit 7718079
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,19 @@
@app.before_request
def check_for_maintenance():
# Don't prevent login or getting assets
if request.path == '/login' or (request.path[:8] == '/assets/'
and '..' not in request.path):
if request.path == '/login' or request.path.startswith('/assets/'):
return

maintenance_mode = bool(os.path.exists('maintenance_mode'))
if maintenance_mode:
if (not check_perm(["ADMIN", "SUPERADMIN"], api_get_perms()) and
request.path[:5] == '/api/'):
return json_fail("The site is currently undergoing maintenance", 503)
if request.path.startswith('/api/'):
if not check_perm(["ADMIN", "SUPERADMIN"], api_get_perms()):
return json_fail("The site is currently undergoing maintenance", 503)
else:
return

# Prevent Internal Server error if session only contains CSRF token
if (not session or 'perms' not in session or
not check_perm(["ADMIN", "SUPERADMIN"])):
if not check_perm(["ADMIN", "SUPERADMIN"]):
return render_template("error/maintenance.html"), 503
else:
flash("Maintenance mode is enabled", "warning")
Expand Down
1 change: 1 addition & 0 deletions src/tests/wintest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fi

# Checkout repo
echo 'Checking out working directory into /tmp/CTFOJ...'
echo 'If cp whines about cannot create symbolic link, ignore it, it is ok'
cp -r .. /tmp/CTFOJ
echo 'Checking out working directory into /tmp/CTFOJ...Done!'

Expand Down

0 comments on commit 7718079

Please sign in to comment.