From a6f29034d18d5a5ce48d879845cce3544b0f8a3c Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 2 Feb 2025 09:46:44 +0200 Subject: feat: Create require_login helper function and improve list update page --- views/global/router.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'views/global') diff --git a/views/global/router.php b/views/global/router.php index 9025113..527ad68 100644 --- a/views/global/router.php +++ b/views/global/router.php @@ -55,6 +55,18 @@ foreach (glob($MODELS_DIR . '/*.php') as $filename) { $TOKEN = (array_key_exists('token', $_COOKIE)) ? ($_COOKIE['token'] ?? "") : (""); +function redirect(string $href) { + echo ''; + exit; +} + +function require_login() { + global $TOKEN; + if ($TOKEN === '') { + redirect('/login'); + } +} + if (str_ends_with($view, '.php')) { require_once $view; } -- cgit v1.2.3