feat: Add guest-only path handling to redirect logged-in users

This commit is contained in:
2026-03-01 22:07:27 +01:00
parent fd0db9b145
commit 70f0e02fa2
2 changed files with 42 additions and 25 deletions

View File

@@ -125,8 +125,8 @@
},
"class.Products.php": {
"type": "-",
"size": 47110,
"lmtime": 1772116324270,
"size": 47926,
"lmtime": 1772127837185,
"modified": false
},
"class.Site.php": {
@@ -173,6 +173,12 @@
"lmtime": 0,
"modified": false
},
"class.CronQueue.php": {
"type": "-",
"size": 2858,
"lmtime": 1772116301682,
"modified": false
},
"class.FacebookAds.php": {
"type": "-",
"size": 29620,
@@ -187,9 +193,9 @@
},
"class.Products.php": {
"type": "-",
"size": 34441,
"lmtime": 1771757529304,
"modified": true
"size": 34756,
"lmtime": 1772126750737,
"modified": false
},
"class.Users.php": {
"type": "-",
@@ -202,12 +208,6 @@
"size": 1453,
"lmtime": 0,
"modified": true
},
"class.CronQueue.php": {
"type": "-",
"size": 2858,
"lmtime": 1772116301682,
"modified": false
}
},
"services": {
@@ -359,19 +359,19 @@
"supplemental_10.tsv": {
"type": "-",
"size": 573,
"lmtime": 0,
"lmtime": 1772126067385,
"modified": false
},
"supplemental_1.tsv": {
"type": "-",
"size": 45,
"lmtime": 0,
"lmtime": 1772126067465,
"modified": false
},
"supplemental_2.tsv": {
"type": "-",
"size": 1331,
"lmtime": 0,
"lmtime": 1772126067543,
"modified": false
},
"supplemental_3.tsv": {
@@ -383,37 +383,37 @@
"supplemental_4.tsv": {
"type": "-",
"size": 385,
"lmtime": 0,
"lmtime": 1772126067628,
"modified": false
},
"supplemental_5.tsv": {
"type": "-",
"size": 436,
"lmtime": 0,
"lmtime": 1772126067716,
"modified": false
},
"supplemental_6.tsv": {
"type": "-",
"size": 45,
"lmtime": 0,
"lmtime": 1772126067798,
"modified": false
},
"supplemental_7.tsv": {
"type": "-",
"size": 297,
"lmtime": 0,
"lmtime": 1772126067881,
"modified": false
},
"supplemental_8.tsv": {
"type": "-",
"size": 449,
"lmtime": 0,
"lmtime": 1772126067984,
"modified": false
},
"supplemental_9.tsv": {
"type": "-",
"size": 45,
"lmtime": 0,
"lmtime": 1772126068068,
"modified": false
}
},
@@ -451,13 +451,13 @@
"style.css": {
"type": "-",
"size": 60877,
"lmtime": 1772117956039,
"lmtime": 1772126786443,
"modified": false
},
"style.css.map": {
"type": "-",
"size": 162739,
"lmtime": 1772117956039,
"lmtime": 1772126786443,
"modified": false
},
"style-old.css": {
@@ -475,7 +475,7 @@
"style.scss": {
"type": "-",
"size": 70931,
"lmtime": 1772117955600,
"lmtime": 1772126785868,
"modified": false
}
},
@@ -550,6 +550,12 @@
"modified": false
}
},
"MEMORY.md": {
"type": "-",
"size": 79,
"lmtime": 1772126214031,
"modified": false
},
"migrations": {
"001_google_ads_settings.sql": {
"type": "-",
@@ -768,8 +774,8 @@
"products": {
"main_view.php": {
"type": "-",
"size": 68170,
"lmtime": 1771757685790,
"size": 70245,
"lmtime": 1772126874952,
"modified": false
},
"product_history.php": {

View File

@@ -116,6 +116,17 @@ foreach ($public_prefixes as $prefix) {
}
}
// Strony tylko dla niezalogowanych (np. formularz logowania)
$guest_only_paths = ['login', 'logowanie', 'users/login', 'users/login_form'];
$is_guest_only = in_array($path, $guest_only_paths)
|| in_array($path_first . '/' . ($segments[1] ?? ''), $guest_only_paths);
if ($user && $is_guest_only)
{
header('Location: /campaigns');
exit;
}
if (!$user && !$is_public)
{
header( 'Location: /login' );