From b73c23bf5518b6a405f87d8004c9dda1a91d7ebd Mon Sep 17 00:00:00 2001 From: andre Date: Tue, 13 Oct 2026 16:56:40 +0100 Subject: [PATCH] feat(dev): environment ribbon and one-click dev login on the public site and auth pages Co-Authored-By: Claude Sonnet 5.5 --- dev_login.php | 3 +- includes/auth_footer.php | 1 + includes/auth_header.php | 1 + includes/dev_toolbar.php | 4 +-- includes/env_ribbon.php | 62 +++++++++++++++++++++++++++++++++++++++ scripts/dev_accounts.php | 6 +++- site/includes/footer.php | 1 + site/includes/include.php | 1 + 8 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 includes/env_ribbon.php diff --git a/dev_login.php b/dev_login.php index bb046a1..25486a4 100644 --- a/dev_login.php +++ b/dev_login.php @@ -13,7 +13,8 @@ if (!is_file($_dev_shared)) { http_response_code(404); exit; } // submódulo s require_once $_dev_shared; platform_dev_login_handle([ - 'roles' => ['admin' => 'admin@mail.pt', 'sysadmin' => 'sysadmin@mail.pt'], + 'roles' => ['client' => 'client@mail.pt', 'staff' => 'staff@mail.pt', + 'admin' => 'admin@mail.pt', 'sysadmin' => 'sysadmin@mail.pt'], 'bootstrap' => function () { global $pdo; require __DIR__ . '/config/db.php'; require_once __DIR__ . '/config/functions.php'; }, 'csrf_ok' => fn(): bool => is_string($_POST['_csrf'] ?? null) && is_string($_SESSION['csrf_token'] ?? null) && $_SESSION['csrf_token'] !== '' && hash_equals($_SESSION['csrf_token'], $_POST['_csrf']), diff --git a/includes/auth_footer.php b/includes/auth_footer.php index d70c087..af57b6d 100644 --- a/includes/auth_footer.php +++ b/includes/auth_footer.php @@ -4,5 +4,6 @@ + diff --git a/includes/auth_header.php b/includes/auth_header.php index 69deafe..8c7ac88 100644 --- a/includes/auth_header.php +++ b/includes/auth_header.php @@ -65,6 +65,7 @@ $app_name = defined('APP_NAME') ? APP_NAME : 'FitMe 3070'; /* 16px inputs stop iOS from auto-zooming on focus */ @media (max-width: 575.98px) { .form-control { font-size: 16px; } .auth-card { padding: 1.5rem; } } +
diff --git a/includes/dev_toolbar.php b/includes/dev_toolbar.php index fdc4889..4a86f4b 100644 --- a/includes/dev_toolbar.php +++ b/includes/dev_toolbar.php @@ -1,11 +1,11 @@ base_url('dev_login'), 'logout_url' => base_url('views/auth/logout.php'), - 'roles' => ['admin' => 'Admin', 'sysadmin' => 'Sysadmin'], + 'roles' => ['client' => 'Cliente', 'staff' => 'Staff', 'admin' => 'Admin', 'sysadmin' => 'Sysadmin'], 'csrf_field' => 'csrf_field', ]); diff --git a/includes/env_ribbon.php b/includes/env_ribbon.php new file mode 100644 index 0000000..21f349d --- /dev/null +++ b/includes/env_ribbon.php @@ -0,0 +1,62 @@ + in both includes/header.php (backoffice) and + * site/includes/head.php (public site). It hangs off html::before / html::after + * rather than a wrapper element, so no page markup has to change and nothing + * can shift the layout: the frame is fixed, on top, and click-through. + * + * Reads env() directly rather than the APP_ENV constant, because the public + * site does not always load config/functions.php. + */ + +$_env = strtolower((string) (function_exists('env') ? env('APP_ENV', 'prod') : 'prod')); +if ($_env === 'prod' || $_env === 'production') return; +?> + diff --git a/scripts/dev_accounts.php b/scripts/dev_accounts.php index a94881e..a3edef8 100644 --- a/scripts/dev_accounts.php +++ b/scripts/dev_accounts.php @@ -9,4 +9,8 @@ declare(strict_types=1); $_dev_shared = dirname(__DIR__) . '/shared/platform-tools/functions_dev.php'; if (!is_file($_dev_shared)) { fwrite(STDERR, "REFUSED: platform-tools sem functions_dev.php\n"); exit(1); } require_once $_dev_shared; -exit(platform_dev_accounts_run(['flags' => ['is_active' => 1]])); +exit(platform_dev_accounts_run([ + 'flags' => ['is_active' => 1], + 'accounts' => ['sysadmin@mail.pt' => 'sysadmin', 'admin@mail.pt' => 'admin', + 'client@mail.pt' => 'client', 'staff@mail.pt' => 'staff'], +])); diff --git a/site/includes/footer.php b/site/includes/footer.php index f982464..af1a51c 100644 --- a/site/includes/footer.php +++ b/site/includes/footer.php @@ -39,5 +39,6 @@ + diff --git a/site/includes/include.php b/site/includes/include.php index 71754e7..363d660 100644 --- a/site/includes/include.php +++ b/site/includes/include.php @@ -85,6 +85,7 @@ $canonical = $GLOBALS['_canonical_override'] ?? match ($page) { +