# Career Page Admin Panel - Secure Version

A Laravel-based admin panel with authentication for managing career/job listings and job applications. Uses SQLite for local testing.

## Security Features

### Authentication & Authorization
- ✅ **Login/Logout System** - Secure authentication using Laravel's built-in auth system
- ✅ **Session Management** - Encrypted session cookies with secure settings
- ✅ **CSRF Protection** - All forms protected against Cross-Site Request Forgery attacks
- ✅ **Route Protection** - All admin routes protected with `auth` and `admin` middleware
- ✅ **Password Hashing** - Passwords hashed using Bcrypt
- ✅ **Remember Me** - Optional "Remember Me" functionality with secure tokens

### Security Headers
- ✅ **X-CSRF-TOKEN** - Meta tag for JavaScript AJAX requests
- ✅ **X-UA-Compatible** - IE compatibility mode
- ✅ **Referrer Policy** - `strict-origin-when-cross-origin`

### Input Validation
- ✅ All forms validated server-side
- ✅ SQL Injection protection via Eloquent ORM
- ✅ XSS protection via Blade's auto-escaping

## Default Login Credentials

```
Email:    admin@galtech.org
Password: admin123
```

## Features

### Career Management
- **Admin Panel** (`/admin/careers`)
  - Create, Read, Update, Delete (CRUD) career listings
  - Full job details matching the existing GALTech website:
    - Title, slug, department, employment type
    - Location (short + full address)
    - Contact email and phone
    - Education requirements
    - Required skills
    - Industry
    - Working hours
    - Salary range and base salary
    - Job description
    - Roles & responsibilities
    - Requirements & qualifications
    - Benefits
    - Date posted and valid through dates
    - Active/inactive status

### Job Application Management
- **Application List** (`/admin/applications`)
  - View all job applications
  - Filter by status (pending, reviewed, shortlisted, rejected, hired)
  - Filter by position/career
  - Search by applicant name, email, or phone
  - Download resumes

- **Application Detail** (`/admin/applications/{id}`)
  - View applicant information
  - View cover letter/message
  - Download resume/CV
  - Update application status
  - Add admin notes
  - View application timeline

## URLs

### Public
| Page | URL |
|------|-----|
| Careers List | `/careers` |
| Career Detail | `/careers/{slug}` |

### Admin (Protected - Requires Login)
| Page | URL |
|------|-----|
| Login | `/login` |
| Logout | `/logout` (POST) |
| Careers Dashboard | `/admin/careers` |
| Create Career | `/admin/careers/create` |
| Edit Career | `/admin/careers/{id}/edit` |
| View Career | `/admin/careers/{id}` |
| Applications Dashboard | `/admin/applications` |
| View Application | `/admin/applications/{id}` |
| Download Resume | `/admin/applications/{id}/resume` |
| Forgot Password | `/forgot-password` |

## Running the Application

1. **Start the server:**
   ```bash
   cd admin-panel
   php artisan serve --port=8001
   ```

2. **Access the admin panel:**
   ```
   http://localhost:8001/login
   ```

3. **Login with credentials:**
   ```
   Email:    admin@galtech.org
   Password: admin123
   ```

4. **After login, you'll be redirected to:**
   ```
   http://localhost:8001/admin/careers
   ```

## Database

SQLite is used for local testing. The database file is located at:
```
database/database.sqlite
```

### Reset Database with Sample Data
```bash
php artisan migrate:fresh --seed
```

This will recreate all tables and add:
- 1 Admin user (admin@galtech.org / admin123)
- 3 Sample careers (Senior SEO Analyst, Digital Marketing Interns, Python Full Stack Trainer)
- 2 Sample job applications

## File Structure

```
admin-panel/
├── app/
│   ├── Http/
│   │   ├── Controllers/
│   │   │   ├── Auth/                    # Authentication controllers
│   │   │   ├── CareerController.php     # Frontend controller
│   │   │   └── Admin/
│   │   │       ├── CareerController.php # Admin career controller
│   │   │       └── JobApplicationController.php
│   │   └── Middleware/
│   │       └── EnsureUserIsAdmin.php    # Admin access middleware
│   └── Models/
│       ├── User.php                     # Authenticatable user
│       ├── Career.php
│       └── JobApplication.php
├── resources/
│   └── views/
│       ├── auth/                        # Login, Register, Password reset
│       ├── layouts/
│       │   ├── admin.blade.php          # Admin layout with logout
│       │   └── guest.blade.php          # Login page layout
│       ├── admin/
│       │   ├── careers/
│       │   │   ├── index.blade.php
│       │   │   ├── create.blade.php
│       │   │   ├── edit.blade.php
│       │   │   └── show.blade.php
│       │   └── applications/
│       │       ├── index.blade.php
│       │       └── show.blade.php
│       └── careers/
│           ├── index.blade.php
│           └── show.blade.php
├── database/
│   └── seeders/
│       └── DatabaseSeeder.php           # Creates admin + sample data
└── routes/
    ├── web.php                          # Main routes (protected)
    └── auth.php                         # Auth routes
```

## Application Statuses

- **Pending** - New application, not yet reviewed
- **Reviewed** - Application has been reviewed
- **Shortlisted** - Candidate is shortlisted for interview
- **Rejected** - Candidate not selected
- **Hired** - Candidate hired for the position

## Security Best Practices Implemented

1. **Authentication Required**: All admin routes require authentication via `auth` middleware
2. **CSRF Tokens**: All forms include `@csrf` directive
3. **Session Security**: Sessions encrypted and stored securely
4. **Password Security**: Bcrypt hashing with appropriate cost factor
5. **Input Sanitization**: All user inputs validated and sanitized
6. **SQL Injection Prevention**: Eloquent ORM used for all database queries
7. **XSS Prevention**: Blade's `{{ }}` syntax auto-escapes output
8. **Secure Headers**: Referrer policy and other security headers set

## Switching to MySQL (Production)

1. Update `.env`:
   ```env
   DB_CONNECTION=mysql
   DB_HOST=127.0.0.1
   DB_PORT=3306
   DB_DATABASE=your_database
   DB_USERNAME=your_username
   DB_PASSWORD=your_password
   ```

2. Run migrations:
   ```bash
   php artisan migrate:fresh --seed
   ```

## Troubleshooting

### "Page Expired" Error
This is CSRF protection working. Refresh the page and try again.

### "Unauthorized" Error
You're not logged in. Navigate to `/login` first.

### Reset Admin Password
```bash
php artisan tinker
>>> \App\Models\User::where('email', 'admin@galtech.org')->first()->update(['password' => \Illuminate\Support\Facades\Hash::make('newpassword')])
```

## Browser Access

Open your browser and navigate to:
- **Admin Login**: http://localhost:8001/login
- **Careers Page**: http://localhost:8001/careers

Use the demo credentials to log in and manage careers and applications.
