79 lines
3.1 KiB
PHP
79 lines
3.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
ob_start();
|
|
require_once __DIR__ . '/db/config.php';
|
|
require_once __DIR__ . '/includes/auth_helper.php';
|
|
|
|
if (Auth::isLoggedIn()) {
|
|
header('Location: index.php', true, 302);
|
|
exit;
|
|
}
|
|
|
|
$error = '';
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$email = trim($_POST['email'] ?? '');
|
|
$password = trim($_POST['password'] ?? '');
|
|
|
|
$stmt = db()->prepare("SELECT * FROM users WHERE email = ? LIMIT 1");
|
|
$stmt->execute([$email]);
|
|
$user = $stmt->fetch();
|
|
|
|
if ($user && password_verify($password, $user['password'])) {
|
|
Auth::login((int)$user['id'], (int)$user['tenant_id'], (string)$user['role']);
|
|
session_write_close();
|
|
header('Location: index.php', true, 302);
|
|
exit;
|
|
} else {
|
|
$error = 'Invalid email or password.';
|
|
}
|
|
}
|
|
|
|
?>
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Login - SR&ED Manager</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
<style>
|
|
body { font-family: 'Inter', sans-serif; background-color: #f8fafc; display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; }
|
|
.login-card { width: 100%; max-width: 400px; border: none; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.05); }
|
|
.btn-primary { background-color: #3b82f6; border: none; padding: 10px; font-weight: 600; }
|
|
.btn-primary:hover { background-color: #2563eb; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="card login-card p-4">
|
|
<div class="text-center mb-4">
|
|
<h3 class="fw-bold text-primary">SR&ED MANAGER</h3>
|
|
<p class="text-muted small">Sign in to your account</p>
|
|
</div>
|
|
|
|
<?php if ($error): ?>
|
|
<div class="alert alert-danger small"><?= htmlspecialchars($error) ?></div>
|
|
<?php endif; ?>
|
|
|
|
<form method="POST">
|
|
<div class="mb-3">
|
|
<label class="form-label small fw-bold">Email Address</label>
|
|
<input type="email" name="email" class="form-control" placeholder="name@company.com" required autofocus>
|
|
</div>
|
|
<div class="mb-3">
|
|
<div class="d-flex justify-content-between">
|
|
<label class="form-label small fw-bold">Password</label>
|
|
<a href="forgot_password.php" class="small text-decoration-none">Forgot?</a>
|
|
</div>
|
|
<input type="password" name="password" class="form-control" placeholder="••••••••" required>
|
|
</div>
|
|
<div class="mb-3 form-check">
|
|
<input type="checkbox" class="form-check-input" id="remember">
|
|
<label class="form-check-label small" for="remember">Remember me</label>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary w-100 mb-3">Login</button>
|
|
</form>
|
|
</div>
|
|
</body>
|
|
</html>
|