( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
session_start();
require_once __DIR__ . '/lib/Db.php';
$error = null; $success = null;
$token = trim($_GET['token'] ?? ($_POST['token'] ?? ''));
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$pass = trim($_POST['password'] ?? '');
$conf = trim($_POST['confirm'] ?? '');
if ($token === '') {
$error = 'Missing reset token';
} elseif ($pass === '' || $conf === '') {
$error = 'Please fill in all required fields';
} elseif ($pass !== $conf) {
$error = 'Passwords do not match';
} else {
$ok = consume_reset_token_and_update_password($token, $pass);
if ($ok) {
$success = 'Your password has been updated. Please sign in.';
} else {
$error = 'Invalid or expired token, or update failed';
}
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Strategy & Content Studio — Reset Password</title>
<link rel="stylesheet" href="assets/styles.css">
</head>
<body>
<header>
<h1>Strategy & Content Studio</h1>
</header>
<div class="layout">
<aside>
<h2 style="color:#f9fafb; font-size:18px; margin-top:0;">Reset Password</h2>
<div style="margin-top:12px; font-size:12px; color:#9ca3af;">Enter a new password for your account.</div>
</aside>
<div class="container">
<div class="card" style="max-width: 520px;">
<div class="hero hero-aws">
<div class="title">Set a new password</div>
<div class="subtitle">Use your one-time token to securely reset access.</div>
<div class="cta-group">
<a class="button secondary" href="auth.php">Back to Sign in</a>
<a class="button secondary" href="forgot.php">Request new link</a>
</div>
</div>
<?php if ($error): ?>
<div class="notice error"><?php echo htmlspecialchars($error, ENT_QUOTES, 'UTF-8'); ?></div>
<?php endif; ?>
<?php if ($success): ?>
<div class="notice">Success: <?php echo htmlspecialchars($success, ENT_QUOTES, 'UTF-8'); ?> <a href="auth.php">Sign in</a></div>
<?php endif; ?>
<form method="post">
<input type="hidden" name="token" value="<?php echo htmlspecialchars($token, ENT_QUOTES, 'UTF-8'); ?>">
<?php if (!$token): ?>
<div class="row"><input type="text" name="token" placeholder="Paste reset token" required></div>
<?php endif; ?>
<div class="row"><input type="password" name="password" placeholder="New password" required></div>
<div class="row"><input type="password" name="confirm" placeholder="Confirm new password" required></div>
<div class="row"><button type="submit">Reset Password</button></div>
</form>
</div>
</div>
</div>
</body>
</html>