Commit 3444b9b9 authored by buttle's avatar buttle

Fixed static file requests.

parent ea8fec95
......@@ -32,7 +32,7 @@ babel = Babel(app)
csrf = CSRFProtect()
csrf.init_app(app)
app.config['APP_VERSION'] = 34
app.config['APP_VERSION'] = 35
app.config['SCHEMA_VERSION'] = 13
app.config['RESERVED_SLUGS'] = ['login', 'static', 'admin', 'admins', 'user', 'users',
......
......@@ -730,7 +730,7 @@ class Installation(db.Document):
return None
else:
print('Schema already up to date')
@classmethod
def isUser(cls, email):
@staticmethod
def isUser(email):
return True if User.objects(email=email).first() else False
......@@ -2,8 +2,8 @@
<html>
<head>
<meta charset="utf-8">
<title>{{ g.site.siteName }}</title>
<link rel="shortcut icon" type="image/png" href="{{g.site.faviconURL()}}"/>
<title>{% if g.site %}{{ g.site.siteName }}{% endif %}</title>
<link rel="shortcut icon" type="image/png" href="{% if g.site %}{{g.site.faviconURL()}}{% endif %}"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="/static/jquery/jquery.min.js"></script>
<script src="/static/jquery/jquery-ui.min.js"></script>
......
......@@ -79,12 +79,19 @@ def anon_required(f):
def sanitized_slug_required(f):
@wraps(f)
def wrap(*args, **kwargs):
if not ('slug' in kwargs and kwargs['slug'] == sanitizeSlug(kwargs['slug'])):
if not 'slug' in kwargs:
if g.current_user:
flash(gettext("That's a nasty slug!"), 'warning')
flash("No slug found!", 'error')
return render_template('page-not-found.html'), 404
else:
return f(*args, **kwargs)
if kwargs['slug'] in app.config['RESERVED_SLUGS']:
if g.current_user:
flash("Reserved slug!", 'warning')
return render_template('page-not-found.html'), 404
if kwargs['slug'] != sanitizeSlug(kwargs['slug']):
if g.current_user:
flash("That's a nasty slug!", 'warning')
return render_template('page-not-found.html'), 404
return f(*args, **kwargs)
return wrap
def sanitized_key_required(f):
......
......@@ -38,13 +38,14 @@ def make_url_for(function, **kwargs):
return url_for(function, **kwargs)
@app.before_request
def before_request():
def before_request():
g.site=None
g.current_user=None
g.isRootUser=False
g.isAdmin=False
g.site=Site.find(hostname=urlparse(request.host_url).hostname)
if '/static' in request.path:
if request.path[0:7] == '/static':
return
g.site=Site.find(hostname=urlparse(request.host_url).hostname)
if 'user_id' in session and session["user_id"] != None:
g.current_user=User.find(id=session["user_id"], hostname=g.site.hostname)
if not g.current_user:
......@@ -64,8 +65,6 @@ def get_locale():
@app.errorhandler(404)
def page_not_found(error):
if not g.site:
g.site=Site.find(hostname=urlparse(request.host_url).hostname)
return render_template('page-not-found.html'), 400
@app.errorhandler(500)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment