You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
2.3 KiB
58 lines
2.3 KiB
<?php
|
|
|
|
if (session_status() === PHP_SESSION_NONE) {
|
|
session_start();
|
|
}
|
|
|
|
require_once __DIR__ . '/default.php';
|
|
require_once __DIR__ . '/auth.php';
|
|
|
|
$message = '';
|
|
$errors = [];
|
|
$token = (string) ($_GET['token'] ?? '');
|
|
|
|
if ($token === '') {
|
|
$errors[] = 'Missing reset token.';
|
|
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$token = (string) ($_POST['token'] ?? '');
|
|
$newPassword = (string) ($_POST['password'] ?? '');
|
|
if ($token === '' || $newPassword === '') {
|
|
$errors[] = 'Please provide a new password.';
|
|
} elseif (completePasswordReset($token, $newPassword)) {
|
|
$message = 'Password updated successfully. You can now log in.';
|
|
} else {
|
|
$errors[] = 'The reset link is invalid or expired.';
|
|
}
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Reset Password - KaI</title>
|
|
<style>
|
|
body { font-family: Arial, sans-serif; background: #1e1e2e; color: #cdd6f4; display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0; }
|
|
.card { background: #11111b; padding: 24px; border-radius: 10px; width: 360px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
|
|
input, button { width: 100%; padding: 10px; border-radius: 6px; border: 1px solid #45475a; background: #313244; color: #fff; margin-top: 10px; }
|
|
button { background: #89b4fa; color: #11111b; font-weight: bold; cursor: pointer; }
|
|
.message { color: #a6e3a1; margin-top: 12px; }
|
|
.error { color: #f38ba8; margin-top: 12px; }
|
|
a { color: #89b4fa; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="card">
|
|
<h1>Create a new password</h1>
|
|
<form method="post">
|
|
<input type="hidden" name="token" value="<?php echo htmlspecialchars($token); ?>">
|
|
<input type="password" name="password" required placeholder="New password">
|
|
<button type="submit">Save new password</button>
|
|
</form>
|
|
<?php if (!empty($errors)): ?><div class="error"><?php echo htmlspecialchars(implode('<br>', $errors)); ?></div><?php endif; ?>
|
|
<?php if ($message !== ''): ?><div class="message"><?php echo htmlspecialchars($message); ?></div><?php endif; ?>
|
|
<p><a href="login.php">Back to login</a></p>
|
|
</div>
|
|
</body>
|
|
</html>
|