20 lines
346 B
PHP
20 lines
346 B
PHP
<?php
|
|
// includes/middleware.php
|
|
|
|
require_once __DIR__ . '/auth.php';
|
|
|
|
function requireLogin() {
|
|
if (!isLoggedIn()) {
|
|
header("Location: /login.php");
|
|
exit;
|
|
}
|
|
}
|
|
|
|
function requireAdmin() {
|
|
requireLogin();
|
|
if (getUserRole() !== 'admin') {
|
|
header("Location: /index.php"); // Or dashboard
|
|
exit;
|
|
}
|
|
}
|