workPro Documentation
A complete RBAC-enabled user management system with:
public/users.php (Main management page)public/api/users-list.php - Fetch all userspublic/api/users-view.php - Get single user detailspublic/api/users-create.php - Create new userpublic/api/users-edit.php - Update user infopublic/api/users-password.php - Change user passwordpublic/api/users-delete.php - Delete user| Role | View Users | Create User | Edit User | Change Password | Delete User |
|---|---|---|---|---|---|
| Admin | ✅ | ✅ | ✅ | ✅ | ✅ |
| Staff | ✅ | ✅ | ✅ | ✅ | ❌ |
| Supervisor | ❌ | ❌ | ❌ | ❌ | ❌ |
| Field | ❌ | ❌ | ❌ | ❌ | ❌ |
✅ Session-based authentication required
✅ Role-based access control on all endpoints
✅ Parameterized queries (SQL injection prevention)
✅ Input validation on all forms
✅ Password hashing with bcrypt
✅ Prevents self-deletion
✅ User cannot see management page if not admin/staff
┌─────────────┬─────────────┬──────────────────┬────────────┬──────────┬─────────────┐
│ Login ID │ Role │ Email │ Phone │ Status │ Actions │
├─────────────┼─────────────┼──────────────────┼────────────┼──────────┼─────────────┤
│ john.doe │ Admin │ john@example.com │ +91 ... │ Active │ 👁️ ✏️ 🔐 🗑️ │
│ jane.smith │ Staff │ jane@example.com │ +91 ... │ Active │ 👁️ ✏️ 🔐 🗑️ │
└─────────────┴─────────────┴──────────────────┴────────────┴──────────┴─────────────┘
Features:
--bg: #0b0f19 /* Dark background */
--card: #121826 /* Card background */
--text: #e5e7eb /* Main text */
--muted: #94a3b8 /* Muted text */
--primary: #10b981 /* Green accent */
--warn: #f59e0b /* Orange warning */
--error: #ef4444 /* Red error */
--border: #1f2937 /* Border color */
CREATE TABLE user (
id INT PRIMARY KEY AUTO_INCREMENT,
loginId VARCHAR(50) UNIQUE NOT NULL,
password_hash VARCHAR(255),
role ENUM('admin', 'staff', 'supervisor', 'field'),
status ENUM('Active', 'Inactive'),
email VARCHAR(100),
phone VARCHAR(20),
vendor_id INT,
project_id INT,
dc_id INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
Purpose: Fetch all users
RBAC: Admin, Staff
Response:
{
"ok": true,
"users": [
{
"id": 1,
"loginId": "john.doe",
"role": "admin",
"email": "john@example.com",
"phone": "+91 ...",
"status": "Active"
}
]
}
Purpose: Get single user details
RBAC: Admin, Staff
Params: id=<user_id>
Response:
{
"ok": true,
"user": {
"id": 1,
"loginId": "john.doe",
"role": "admin",
"email": "john@example.com",
"phone": "+91 ...",
"status": "Active"
}
}
Purpose: Create new user
RBAC: Admin, Staff
Parameters:
loginId (required)role (required) - admin, staff, supervisor, fieldstatus (optional) - Active, Inactiveemail (optional)phone (optional)Response:
{
"ok": true,
"message": "User created successfully. Default password is 'password'"
}
Purpose: Update user information
RBAC: Admin, Staff
Params: id=<user_id>
Parameters:
role (required)status (required)email (optional)phone (optional)Response:
{
"ok": true,
"message": "User updated successfully"
}
Purpose: Change user password
RBAC: Admin, Staff
Params: id=<user_id>
Parameters:
password (required) - 8+ charactersResponse:
{
"ok": true,
"message": "Password changed successfully"
}
Purpose: Delete user
RBAC: Admin only
Params: id=<user_id>
Response:
{
"ok": true,
"message": "User deleted successfully"
}
/public/users.phppassword✅ Always use HTTPS in production
✅ Keep password hashing algorithm updated (bcrypt)
✅ Audit user modifications with timestamps
✅ Review deleted users in audit logs
✅ Regular security audits of user management
✅ SQL Injection - Parameterized queries
✅ XSS Attacks - htmlspecialchars() in output
✅ CSRF - Session-based authentication
✅ Privilege Escalation - Role-based API checks
✅ Unauthorized Access - Login requirement
Potential features to add:
For issues or questions:
Status: ✅ Production Ready
Last Updated: December 18, 2025
Version: 1.0