From 69e1ef75a0e0b62983367f1c5d5fa51c9b9c3596 Mon Sep 17 00:00:00 2001 From: INOPIAE Date: Tue, 9 Apr 2019 22:38:12 +0200 Subject: [PATCH] upd: add configurable debug user --- config.py.example | 2 ++ motion.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/config.py.example b/config.py.example index 3ad653f..25b8123 100644 --- a/config.py.example +++ b/config.py.example @@ -7,3 +7,5 @@ DEFAULT_HOST="hostname for migration from db version < 2" GROUP_PREFIX={'hostname': {'group1': 'g1', 'group2': 'g2'}} # motion types and their id-prefixes DURATION={'hostname':[3, 7, 14]} # duration period for motions + +#DEBUGUSER={'hostname':'username/create:* vote:*'} # remove # at beginning of line to use local debuguser diff --git a/motion.py b/motion.py index f835f99..eb04eff 100644 --- a/motion.py +++ b/motion.py @@ -22,12 +22,19 @@ prefix=app.config.get("GROUP_PREFIX") times=app.config.get("DURATION") +debuguser=app.config.get("DEBUGUSER") + @app.before_request def lookup_user(): global prefix env = request.environ user = None + if debuguser is not None: + parts =debuguser[request.host].split("/", 1) + user = parts[0] + roles = parts[1] + if "USER_ROLES" in env: parts = env.get("USER_ROLES").split("/", 1) user = parts[0] -- 2.39.2