2.0.0 Beta : Self-hosted Release
This commit is contained in:
+32
-1
@@ -3,7 +3,7 @@ import os
|
||||
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
||||
|
||||
from flask import Flask
|
||||
from flask import Flask, redirect, request, session, url_for
|
||||
from web.config import Config
|
||||
from web.database import close_dbs, initialize_web_db
|
||||
from web.auth import get_csrf_token
|
||||
@@ -19,8 +19,38 @@ def create_app(config_object=Config):
|
||||
app.teardown_appcontext(close_dbs)
|
||||
app.jinja_env.globals['csrf_token'] = get_csrf_token
|
||||
|
||||
@app.context_processor
|
||||
def inject_brand():
|
||||
return {
|
||||
'brand': {
|
||||
'primary': app.config['BRAND_PRIMARY'],
|
||||
'aliases': app.config['BRAND_ALIASES'],
|
||||
'signature': app.config['BRAND_SIGNATURE'],
|
||||
}
|
||||
}
|
||||
|
||||
@app.before_request
|
||||
def require_private_access():
|
||||
if app.config['SITE_VISIBILITY'] != 'private':
|
||||
return None
|
||||
endpoint = request.endpoint or ''
|
||||
if (
|
||||
endpoint == 'static'
|
||||
or endpoint == 'main.healthz'
|
||||
or endpoint.startswith('access.')
|
||||
or endpoint.startswith('admin.')
|
||||
or session.get('viewer_access')
|
||||
or session.get('is_admin')
|
||||
):
|
||||
return None
|
||||
return redirect(url_for(
|
||||
'access.login',
|
||||
next=request.full_path if request.method == 'GET' else None,
|
||||
))
|
||||
|
||||
from web.routes import (
|
||||
admin,
|
||||
access,
|
||||
awards,
|
||||
discover,
|
||||
main,
|
||||
@@ -33,6 +63,7 @@ def create_app(config_object=Config):
|
||||
wiki,
|
||||
)
|
||||
app.register_blueprint(main.bp)
|
||||
app.register_blueprint(access.bp)
|
||||
app.register_blueprint(matches.bp)
|
||||
app.register_blueprint(players.bp)
|
||||
app.register_blueprint(teams.bp)
|
||||
|
||||
Reference in New Issue
Block a user