-- Fix Admin Password Script
-- This script will update the admin user password to a properly hashed bcrypt password
-- Password will be: ChangeMe123!
-- Run this in phpMyAdmin or MySQL command line

USE uae_system;

-- First, let's see the current admin user
SELECT id, name, email, LEFT(password, 20) as password_start, is_admin 
FROM users 
WHERE email = 'admin@dextratechnologies.com';

-- Update the admin user with a properly hashed password
-- This is the bcrypt hash for 'ChangeMe123!'
UPDATE users 
SET password = '$2y$12$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi',
    is_admin = 1,
    name = 'Travel System Cost Admin'
WHERE email = 'admin@dextratechnologies.com';

-- If the user doesn't exist, create it
INSERT INTO users (name, email, password, is_admin, created_at, updated_at)
SELECT 'Travel System Cost Admin', 'admin@dextratechnologies.com', '$2y$12$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 1, NOW(), NOW()
FROM DUAL
WHERE NOT EXISTS (
    SELECT 1 FROM users WHERE email = 'admin@dextratechnologies.com'
);

-- Verify the update
SELECT id, name, email, LEFT(password, 20) as password_start, is_admin 
FROM users 
WHERE email = 'admin@dextratechnologies.com';

-- Done! You can now login with:
-- Email: admin@dextratechnologies.com
-- Password: ChangeMe123!
