107 lines
3.4 KiB
PHP
107 lines
3.4 KiB
PHP
<?php
|
|
require_once 'includes/auth.php';
|
|
|
|
if (isAuthenticated() && isSessionValid()) {
|
|
header('Location: dashboard.php');
|
|
exit;
|
|
}
|
|
|
|
$message = '';
|
|
$messageType = '';
|
|
|
|
if (isset($_GET['error'])) {
|
|
switch ($_GET['error']) {
|
|
case 'session_expired':
|
|
$message = 'Your session has expired. Please log in again.';
|
|
$messageType = 'warning';
|
|
break;
|
|
default:
|
|
$message = 'An error occurred. Please try again.';
|
|
$messageType = 'error';
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (isset($_GET['message'])) {
|
|
switch ($_GET['message']) {
|
|
case 'logged_out':
|
|
$message = 'You have been logged out successfully.';
|
|
$messageType = 'info';
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (isset($loginError)) {
|
|
$message = $loginError;
|
|
$messageType = 'error';
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?php echo APP_NAME; ?> - Login</title>
|
|
<link rel="stylesheet" href="/assets/css/style.css">
|
|
</head>
|
|
<body>
|
|
<div class="login-container">
|
|
<div class="login-card">
|
|
<div class="login-header">
|
|
<h1><?php echo APP_NAME; ?></h1>
|
|
<p>Router Enrollment Management Interface</p>
|
|
<p class="text-sm text-secondary">Version <?php echo APP_VERSION; ?></p>
|
|
</div>
|
|
|
|
<?php if ($message): ?>
|
|
<div class="alert alert-<?php echo $messageType; ?>">
|
|
<?php echo htmlspecialchars($message); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<form method="POST" action="index.php">
|
|
<input type="hidden" name="action" value="login">
|
|
|
|
<div class="form-group">
|
|
<label for="username" class="form-label">Username</label>
|
|
<input
|
|
type="text"
|
|
id="username"
|
|
name="username"
|
|
class="form-input"
|
|
required
|
|
autocomplete="username"
|
|
value="<?php echo isset($_POST['username']) ? htmlspecialchars($_POST['username']) : ''; ?>"
|
|
>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="password" class="form-label">Password</label>
|
|
<input
|
|
type="password"
|
|
id="password"
|
|
name="password"
|
|
class="form-input"
|
|
required
|
|
autocomplete="current-password"
|
|
>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary btn-full">
|
|
Sign In
|
|
</button>
|
|
</form>
|
|
|
|
<div style="margin-top: 2rem; padding-top: 1rem; border-top: 1px solid #e0e0e0; text-align: center;">
|
|
<p class="text-sm text-secondary">
|
|
Default credentials: <strong>admin</strong> / <strong>admin123</strong>
|
|
</p>
|
|
<p class="text-xs text-secondary" style="margin-top: 0.5rem;">
|
|
Please change the default password in production
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|