feat(dev): environment ribbon and one-click dev login on the public site and auth pages

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
andreandClaude Sonnet 5.5 committed 2026-10-13 16:56:40 +01:00
1 parent 5f64ae57db
commit b73c23bf55
8 files changed
+75 -4

No files matched your search

+1
View File
@@ -4,5 +4,6 @@
</main>
<script src="<?= base_url('assets/vendor/bootstrap5/js/bootstrap.bundle.min.js') ?>"></script>
<?= script_tag('assets/js/password-toggle.js') ?>
<?php include __DIR__ . '/dev_toolbar.php'; // DEV ONLY: sem saída fora de dev ?>
</body>
</html>
+1
View File
@@ -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; } }
</style>
<?php include __DIR__ . '/env_ribbon.php'; // moldura de aviso fora de produção ?>
</head>
<body>
<main class="auth-card">
+2 -2
View File
@@ -1,11 +1,11 @@
<?php
// DEV ONLY -- barra de login de um clique (platform-tools). Não imprime nada
// fora de dev. Incluída por includes/footer.php.
// fora de dev. Incluída por includes/footer.php, auth_footer.php e site/includes/footer.php.
require_once __DIR__ . '/../config/dev_guard.php';
if (!function_exists('platform_dev_toolbar')) return;
platform_dev_toolbar([
'login_url' => 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',
]);
+62
View File
@@ -0,0 +1,62 @@
<?php
/**
* Non-production environment marker.
*
* Dev and prod are the same codebase on near-identical URLs, so it is genuinely
* easy to edit a real client's session while believing you are on dev. This
* paints an unmissable hazard frame around every page whenever APP_ENV is not
* 'prod', plus a corner chip naming the environment.
*
* Included from <head> 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;
?>
<style>
/* Faixa de aviso de ambiente — só fora de produção. */
html::after {
content: '';
position: fixed;
inset: 0;
z-index: 2147483646;
pointer-events: none; /* nunca intercepta cliques */
border: 6px solid transparent;
border-image: repeating-linear-gradient(
45deg,
#111 0 14px,
#f5c400 14px 28px
) 6;
}
html::before {
content: '<?= htmlspecialchars(strtoupper($_env), ENT_QUOTES) ?>';
position: fixed;
top: 6px;
left: 50%;
transform: translateX(-50%);
z-index: 2147483647;
pointer-events: none;
padding: .1rem .8rem .15rem;
background: #f5c400;
color: #111;
font: 700 .7rem/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
letter-spacing: .18em;
border-radius: 0 0 .35rem .35rem;
box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
/* Em ecrãs pequenos a moldura rouba demasiado espaço horizontal. */
@media (max-width: 575.98px) {
html::after { border-width: 4px; border-image-slice: 4; }
html::before { font-size: .6rem; top: 4px; }
}
/* Ao imprimir não faz sentido nenhum. */
@media print {
html::after, html::before { display: none; }
}
</style>