The Mirhal platform now includes an admin approval system for new hosts. When users apply to become hosts, their applications must be reviewed and approved by the admin before they can list vehicles.
Admin Email: abdulazizalbadi91@gmail.com
- User fills out the "Become a Host" form
- Application is saved with status:
pending - Admin receives an email notification
- Admin logs in with abdulazizalbadi91@gmail.com
- Reviews host applications in the admin dashboard
- Can approve or reject applications
- Approved hosts receive congratulations email
- Rejected hosts receive notification with reason
- Approved hosts can immediately start listing vehicles
All admin endpoints require authentication and admin privileges.
http://localhost:5001/api/admin
All requests must include:
Authorization: Bearer <firebase_id_token>
Get all pending host applications.
Response:
{
"pendingHosts": [
{
"_id": "user_id",
"name": "John Doe",
"email": "john@example.com",
"hostProfile": {
"approvalStatus": "pending",
"requestedAt": "2025-10-29T12:00:00.000Z",
"phone": "+1234567890",
"bio": "..."
},
"createdAt": "2025-10-28T10:00:00.000Z"
}
]
}Get all hosts (approved, pending, or rejected).
Query Parameters:
status(optional):pending,approved, orrejected
Response:
{
"hosts": [
{
"_id": "user_id",
"name": "Jane Smith",
"email": "jane@example.com",
"hostProfile": {
"approvalStatus": "approved",
"approvedBy": {
"name": "Admin Name",
"email": "admin@example.com"
},
"approvedAt": "2025-10-29T11:30:00.000Z"
}
}
]
}Approve a host application.
Request:
PUT /api/admin/approve-host/65abc123def456789Response:
{
"message": "Host approved successfully",
"user": {
"id": "65abc123def456789",
"name": "John Doe",
"email": "john@example.com",
"approvalStatus": "approved"
}
}Email Sent:
- Host receives approval email with next steps
Reject a host application.
Request:
PUT /api/admin/reject-host/65abc123def456789
Content-Type: application/json
{
"reason": "Incomplete application. Please provide valid documentation."
}Response:
{
"message": "Host rejected",
"user": {
"id": "65abc123def456789",
"name": "John Doe",
"email": "john@example.com",
"approvalStatus": "rejected"
}
}Email Sent:
- Host receives rejection email with reason
Get admin dashboard statistics.
Response:
{
"stats": {
"pendingHosts": 5,
"approvedHosts": 42,
"rejectedHosts": 3,
"totalUsers": 150
}
}Subject: ποΈ New Host Application - John Doe
Hello Admin,
A new host application has been submitted...
π€ HOST DETAILS:
ββββββββββββββββββββββββββββββββ
β’ Name: John Doe
β’ Email: john@example.com
β’ Phone: +1234567890
β’ Applied: 10/29/2025, 1:00 PM
β‘ ACTION REQUIRED:
Please log in to review this application.
Subject: π Your Host Application is Approved!
Congratulations! Your host application has been APPROVED!
You can now:
β
List your RVs and campers
β
Set your own pricing
β
Accept booking requests
β
Start earning money!
π NEXT STEPS:
1. Log in to your account
2. Go to "Become a Host"
3. Add your first vehicle
Subject: π Update on Your Host Application
Thank you for your interest in becoming a host.
Unfortunately, we are unable to approve your application at this time.
π REASON:
[Admin's reason here]
π WHAT'S NEXT?
β’ Reply with additional information
β’ Contact support
β’ Resubmit after addressing feedback
{
role: {
type: String,
enum: ['renter', 'host', 'both', 'admin'],
default: 'renter'
},
isAdmin: {
type: Boolean,
default: false
},
hostProfile: {
isApproved: Boolean, // Quick check
approvalStatus: String, // 'pending', 'approved', 'rejected'
approvedBy: ObjectId, // Admin who approved
approvedAt: Date, // When approved
rejectionReason: String, // Why rejected
requestedAt: Date, // When applied
// ... other fields
}
}# User applies to be a host via frontend
# Or via API:
POST /api/users/become-hostYou'll see:
π§ EMAIL SENT (Development Mode)
To: abdulazizalbadi91@gmail.com
Subject: ποΈ New Host Application - John Doe
[Full email content]
# Log in as abdulazizalbadi91@gmail.com
# Then:
curl -X PUT http://localhost:5001/api/admin/approve-host/USER_ID \
-H "Authorization: Bearer YOUR_TOKEN"π§ EMAIL SENT (Development Mode)
To: john@example.com
Subject: π Your Host Application is Approved!
[Full email content]
// MongoDB shell or script
db.users.updateOne(
{ email: 'abdulazizalbadi91@gmail.com' },
{ $set: { isAdmin: true, role: 'admin' } }
);See EMAIL_SETUP.md for email configuration.
Create admin pages for:
- Viewing pending applications
- Approving/rejecting hosts
- Viewing host statistics
β Admin Check:
- Middleware checks if user email === 'abdulazizalbadi91@gmail.com'
- OR if user.isAdmin === true
- Unauthorized users get 403 Forbidden
β Authentication Required:
- All admin routes require valid Firebase token
- Token verified before any operation
β Email Validation:
- Admin email hardcoded in middleware
- Cannot be changed without code update
Consider adding:
- Multiple admin users
- Role-based permissions (super admin, moderator)
- Admin activity logs
- Batch approve/reject
- Automated approval based on criteria
- Host verification documents upload
- Admin dashboard frontend
- Push notifications for new applications
server/models/User.js- Added admin fieldsserver/middleware/admin.js- Admin authentication (NEW)server/routes/admin.js- Admin routes (NEW)server/services/emailService.js- Host approval emailsserver/index.js- Registered admin routes
ADMIN_SYSTEM.md- This file (NEW)EMAIL_SETUP.md- Email configuration guide
- Backend running: β (port 5001)
- MongoDB connected: β
- Admin email: abdulazizalbadi91@gmail.com
- Test it:
- Have a user apply to be a host
- Check server console for admin email
- Use admin API to approve/reject
- Check console for host notification email
Everything is ready to go!