# Fix Admin Password Issue

## Problem
You're getting this error when trying to login:
```
This password does not use the Bcrypt algorithm.
```

This means the admin user's password in the database is stored as plain text instead of being properly hashed.

## Solution Options

### Option 1: Using phpMyAdmin (Easiest)

1. **Open phpMyAdmin** from XAMPP Control Panel
2. **Select the `uae_system` database**
3. **Click on "SQL" tab**
4. **Copy and paste this SQL code:**

```sql
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';
```

5. **Click "Go"**
6. **Done!** You can now login with:
   - Email: `admin@dextratechnologies.com`
   - Password: `ChangeMe123!`

### Option 2: Using MySQL Command Line

1. **Open Command Prompt** or PowerShell
2. **Connect to MySQL:**
   ```bash
   mysql -u root -p
   ```
3. **Enter your MySQL password** (if you have one)
4. **Run these commands:**
   ```sql
   USE uae_system;
   
   UPDATE users 
   SET password = '$2y$12$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi',
       is_admin = 1
   WHERE email = 'admin@dextratechnologies.com';
   
   exit;
   ```

### Option 3: Using the SQL File

1. **Start MySQL** in XAMPP
2. **Open PowerShell** and navigate to your project:
   ```powershell
   cd d:\xampp\htdocs\uae-travel-system
   ```
3. **Run the SQL file:**
   ```powershell
   mysql -u root -p uae_system < fix-admin-password.sql
   ```
4. **Press Enter** (or enter your MySQL password if you have one)

### Option 4: Using Laravel Artisan (When Database is Connected)

If your database connection is working from the web interface:

1. **Open PowerShell** and navigate to your project:
   ```powershell
   cd d:\xampp\htdocs\uae-travel-system
   ```
2. **Run the fix script:**
   ```powershell
   php fix-admin-password.php
   ```

## Verify the Fix

After running any of the above solutions:

1. Go to: http://localhost:8000/admin/login (or http://127.0.0.1:9876/admin/login if using a different port)
2. Login with:
   - **Email:** `admin@dextratechnologies.com`
   - **Password:** `ChangeMe123!`

## Change Password After Login

⚠️ **IMPORTANT:** After successfully logging in, change your password immediately!

### Method 1: Using Laravel Tinker

```powershell
cd d:\xampp\htdocs\uae-travel-system
php artisan tinker
```

Then in tinker:
```php
$user = User::where('email', 'admin@dextratechnologies.com')->first();
$user->password = Hash::make('YourNewSecurePassword123!');
$user->save();
exit
```

### Method 2: Using phpMyAdmin

Generate a new bcrypt hash online at: https://bcrypt-generator.com/

Then update in phpMyAdmin:
```sql
UPDATE users 
SET password = 'your-generated-bcrypt-hash-here'
WHERE email = 'admin@dextratechnologies.com';
```

## Why This Happened

The password in your database was stored as plain text or with a different hashing algorithm. Laravel 11 requires passwords to be hashed using Bcrypt with the following format:
- Starts with `$2y$`
- Example: `$2y$12$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi`

## Prevent This in Future

Always use Laravel's `Hash::make()` when setting passwords:

```php
use Illuminate\Support\Facades\Hash;

$user->password = Hash::make('the-password');
$user->save();
```

Never store plain text passwords:
```php
// ❌ WRONG - Never do this
$user->password = 'plain-text-password';

// ✅ CORRECT - Always hash passwords
$user->password = Hash::make('plain-text-password');
```

## Still Having Issues?

If you're still experiencing problems:

1. **Check if MySQL is running** in XAMPP Control Panel
2. **Verify database name** is `uae_system` in your `.env` file
3. **Check database credentials** in `.env`:
   ```env
   DB_CONNECTION=mysql
   DB_HOST=127.0.0.1
   DB_PORT=3306
   DB_DATABASE=uae_system
   DB_USERNAME=root
   DB_PASSWORD=
   ```
4. **Clear Laravel cache:**
   ```powershell
   php artisan config:clear
   php artisan cache:clear
   ```

## Security Best Practices

1. ✅ Change default password immediately after first login
2. ✅ Use strong passwords (12+ characters, mix of letters, numbers, symbols)
3. ✅ Never share admin credentials
4. ✅ Always hash passwords using `Hash::make()`
5. ✅ Set `APP_ENV=production` and `APP_DEBUG=false` before going live

---

**The bcrypt hash provided in this guide is for the password:** `ChangeMe123!`

After fixing the issue, you should be able to login successfully! 🎉
