Overview
The user profile is a customer-facing dashboard where registered users can:- View active and historical reservations
- Manage their “virtual garage” (saved vehicles)
- Edit personal information and password
- Cancel or modify pending reservations
Route:
Controller:
View:
Client Script:
/users/profile (requires authentication)Controller:
controllers/authController.js:renderProfile() (line 248-278)View:
views/profile.ejsClient Script:
public/javascripts/profile.jsPage Layout
The profile page is divided into two main panels:Left Panel
Account Information
- Name, email, phone display
- “Edit Data” button
- Current active reservations (PENDIENTE, EN CURSO)
Right Panel
Booking History
- Past reservations (FINALIZADA, CANCELADA)
- Click to view details
- Filtered list with scrolling
Data Loading
When the profile loads, the server fetches all necessary data in parallel for performance:Reservation Filtering
Active Reservations
Display Cards
Each active reservation shows:Click Interaction
Clicking a reservation card opens a modal with full details:Reservation Details Modal
When a reservation is clicked, a modal displays:Information Shown
Information Shown
- Reservation ID:
#42 - Entry Date:
15/3/2024, 9:00:00 - Exit Date:
20/3/2024, 18:00:00 - Service: “Premium Parking”
- Vehicle:
1234ABC (Toyota Corolla) - Total Price:
125.50 € - Status Badge: Color-coded based on state
Action Buttons
Cancel Booking
Only for PENDIENTE reservationsDELETE Sets status to
/users/profile/reservation/:id/cancelValidation (authController.js:366-368):CANCELADA and frees parking spot.Edit Booking
For PENDIENTE and EN CURSOOpens another modal with editable fields:
- Entry date (locked if EN CURSO)
- Exit date
- Main service selector
- Additional services checkboxes
/users/profile/reservation/:id/editServer recalculates price to prevent tampering.Edit Reservation Flow
Frontend Modal
Backend Update Logic
Route:PUT /users/profile/reservation/:id/editController:
authController.js:382-436
Account Settings
Users can edit two categories of information via tabbed modal:Personal Data Tab
Fields:- Full Name
- Phone Number
PUT /users/profile/updateController:
authController.js:281-305
Session is updated so the navigation bar immediately reflects the new name without re-login.
Password Tab
Fields:- Current Password (verification)
- New Password
- Confirm New Password
PUT /users/profile/passwordController:
authController.js:308-345
Virtual Garage (Vehicle Management)
The system automatically tracks vehicles associated with the user:How Vehicles Are Added
- During Booking: When user creates a reservation, the vehicle is added to
vehicletable and linked viacustomer_vehicle - Auto-link: Existing vehicles (by license plate) are automatically linked if used in new reservation
Data Structure
Frontend Display
Vehicles are loaded in profile via:Booking History
Filtering
History panel shows only completed/cancelled reservations:No Actions Allowed
Unlike active reservations, historical ones are read-only:- Cannot cancel (already finished/cancelled)
- Cannot edit (immutable for accounting)
- Can view details for records
Security & Permissions
Authentication Middleware
Authentication Middleware
Profile route requires valid session:
Ownership Validation
Ownership Validation
All reservation actions verify
id_customer:Status-based Permissions
Status-based Permissions
- PENDIENTE: Can cancel or edit
- EN CURSO: Can edit (with restrictions) but not cancel
- FINALIZADA/CANCELADA: View only
UI/UX Features
Scrollable Lists
Active reservations limited to 250px height with overflow scroll (profile.ejs:41)
Status Color Coding
CSS classes:
.badge-pendiente(yellow).badge-en-curso(blue).badge-finalizada(green).badge-cancelada(red)
Modal System
3 modals:
- Edit Profile (with tabs)
- Reservation Details
- Edit Reservation
SweetAlert2
Used for:
- Success messages
- Error alerts
- Confirmation dialogs (e.g., “Cancel this booking?”)
Code References
| Feature | File | Line Range |
|---|---|---|
| Profile Render | controllers/authController.js | 248-278 |
| Update Profile | controllers/authController.js | 281-305 |
| Change Password | controllers/authController.js | 308-345 |
| Cancel Reservation | controllers/authController.js | 348-379 |
| Edit Reservation | controllers/authController.js | 382-436 |
| View Template | views/profile.ejs | Full file |
| Client Logic | public/javascripts/profile.js | Modal handlers |
| Customer DAO | models/customer-dao.js | CRUD operations |
| Reservation DAO | models/reservation-dao.js | getReservationsByCustomerId() (574-600) |
Error Scenarios
Next Steps
Public Booking
How users create reservations
Reservation Lifecycle
State transitions and admin processing
