<?php
require_once('includes/config.php');

echo "=== RESETTING PASSWORDS ===\n";

// 1. Reset Admin Password (Bcrypt)
$adminEmail = 'admin2@awesomemall.com';
$adminNewPass = 'admin123';
$adminHash = password_hash($adminNewPass, PASSWORD_DEFAULT);

$stmt = $con->prepare("UPDATE users SET password = ? WHERE email = ? AND role = 'admin'");
$stmt->bind_param("ss", $adminHash, $adminEmail);
$stmt->execute();
if ($stmt->affected_rows > 0) {
    echo "[SUCCESS] Admin ($adminEmail) password reset to '$adminNewPass' (Bcrypt).\n";
} else {
    echo "[INFO] Admin ($adminEmail) password not updated (maybe email not found or same pass).\n";
}
$stmt->close();


// 2. Reset Vendor Password (MD5 - for testing legacy, or Bcrypt if upgraded)
// Let's use Bcrypt to test the new logic!
$vendorEmail = 'vendor@test.com';
$vendorNewPass = '123456';
$vendorHash = password_hash($vendorNewPass, PASSWORD_DEFAULT);

$stmt = $con->prepare("UPDATE users SET password = ? WHERE email = ? AND role = 'vendor'");
$stmt->bind_param("ss", $vendorHash, $vendorEmail);
$stmt->execute();
if ($stmt->affected_rows > 0) {
    echo "[SUCCESS] Vendor ($vendorEmail) password reset to '$vendorNewPass' (Bcrypt).\n";
} else {
    echo "[INFO] Vendor ($vendorEmail) password not updated (maybe email not found or same pass).\n";
}
$stmt->close();

echo "=== DONE ===\n";
?>
