From 507f0d060da30a8f65bec8b2ac1f08837d536b4c Mon Sep 17 00:00:00 2001 From: cbdev Date: Mon, 4 Jul 2022 19:21:34 +0200 Subject: Implement authentication modules for admin panel --- backend/main.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'backend/main.py') diff --git a/backend/main.py b/backend/main.py index d1042d8..2156d0e 100644 --- a/backend/main.py +++ b/backend/main.py @@ -5,12 +5,12 @@ import os import sqlite3 import mimetypes +import Admin +from utils import redirect + def playout(filename, content = "text/html"): return ["", [('Content-Type', content if content else "application/octet-stream"), ("X-Accel-Redirect", filename)], None] -def redirect(target): - return ["", [('Content-Type','text/html'), ("Location", target)], "302 Redirect"] - def target_filename_internal(alias, filename): target = alias["path"] + "/" if filename: @@ -72,14 +72,21 @@ def upload(alias, post): return ["", [('Content-Type','text/html')], "500 Error"] def route(path, env, post): + if len(path) == 1 and not path[0]: + return config.Auth.login(env, post) + + if path[0] == "admin": + return Admin.route(path, env, post) + + if path[0] == "favicon.ico": + return playout("/assets/favicon.ico") + # Get mapped user/path/limits alias = resolve_alias(path[0]) if not alias: return redirect(config.homepage) - #print(json.dumps(alias)) - # Redirect if no slash after alias if len(path) == 1: return redirect(path[0] + "/"); -- cgit v1.2.3