Selaa lähdekoodia

Show 401 error if page exists

JoostSijm 6 vuotta sitten
vanhempi
commit
92b45258e7
1 muutettua tiedostoa jossa 8 lisäystä ja 2 poistoa
  1. 8 2
      app/modules/static/app.py

+ 8 - 2
app/modules/static/app.py

@@ -3,6 +3,7 @@
 Serve static content
 """
 
+import os
 from flask import render_template, Blueprint, abort
 from jinja2 import TemplateNotFound
 from flask_login import current_user
@@ -18,9 +19,14 @@ BLUEPRINT = Blueprint(
 @BLUEPRINT.route("/<path:page>")
 def show(page):
     """Display static page"""
-    try:
-        if current_user.is_authenticated:
+    if current_user.is_authenticated:
+        try:
             return render_template("private/%s.html" % page)
+        except TemplateNotFound:
+            abort(404)
+    try:
         return render_template("public/%s.html" % page)
     except TemplateNotFound:
+        if os.path.exists("app/modules/static/pages/private/%s.html" % page):
+            abort(401)
         abort(404)