aboutsummaryrefslogtreecommitdiff
path: root/views/global/router.php
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2025-02-02 09:46:44 +0200
committerSyndamia <kamen@syndamia.com>2025-02-02 09:46:44 +0200
commita6f29034d18d5a5ce48d879845cce3544b0f8a3c (patch)
tree8114c4ca6af34e04ecbab67a2359be7d92951db7 /views/global/router.php
parent40b78735aeba6082363e6a8d98b78da9ba230687 (diff)
downloadnowayforward_human-a6f29034d18d5a5ce48d879845cce3544b0f8a3c.tar
nowayforward_human-a6f29034d18d5a5ce48d879845cce3544b0f8a3c.tar.gz
nowayforward_human-a6f29034d18d5a5ce48d879845cce3544b0f8a3c.zip
feat: Create require_login helper function and improve list update page
Diffstat (limited to 'views/global/router.php')
-rw-r--r--views/global/router.php12
1 files changed, 12 insertions, 0 deletions
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 '<script type="text/javascript">window.location.href = "' . $href . '";</script>';
+ exit;
+}
+
+function require_login() {
+ global $TOKEN;
+ if ($TOKEN === '') {
+ redirect('/login');
+ }
+}
+
if (str_ends_with($view, '.php')) {
require_once $view;
}