Overview
The User Management module allows administrators to create, edit, activate/deactivate, and delete users. Users can be assigned to roles, locations, and have their credentials managed centrally.User management requires the
users:full_access permission. Viewing users only requires users:read.Accessing User Management
Navigate to Administration → Users from the sidebar to access the user management interface.User Data Model
Each user in MLM CMMS has the following properties:| Field | Type | Description |
|---|---|---|
id | UUID | Unique identifier (from Supabase Auth) |
email | String | User’s email address (login credential) |
name | String | First name |
last_name | String | Last name |
phone | String | Optional phone number |
location_id | Integer | Associated location/facility |
rol_id | Integer | Assigned role (defines permissions) |
is_active | Boolean | Whether the user can log in |
created_at | Timestamp | Account creation date |
password_reset_at | Timestamp | Last password reset (if available) |
password_reset_by | UUID | Admin who reset the password |
User Management Workflows
Creating a New User
Fill in Required Fields
- Name: User’s first name
- Last Name: User’s surname
- Email: Must be unique across the system
- Password: Use the “Generar segura” button to create a secure password
- Role: Select a role (requires
rbac:manage_rolespermission) - Location (optional): Assign the user to a location
Editing a User
Modify Fields
You can update:
- Name and last name
- Phone number
- Location assignment
- Role assignment (if you have
rbac:manage_roles)
Email cannot be changed in the edit modal.
Resetting a User’s Password
Administrators withusers:full_access can reset user passwords:
Activating/Deactivating Users
Deactivating a user prevents them from logging in without deleting their account:- Single User
- Bulk Deactivation
- Click the “Desactivar” or “Activar” button on the user’s row
- Confirm the action in the confirmation dialog
- The
is_activeflag is toggled in the database
Requires
users:cancel permission for activation/deactivation.Deleting a User
Confirm Prerequisites
Ensure the user has no critical dependencies (e.g., active work orders, tickets).
users:delete permission.
Filtering and Search
The user management interface supports:- Search: By name, last name, or email (minimum 2 characters)
- Location Filter: Show only users from a specific location
- Include Inactive: Toggle to include deactivated users
Pagination
Users are paginated with 8 records per page. Use the “Anterior” and “Siguiente” buttons to navigate pages.Search results disable pagination and show all matching users.
Permissions Required
| Action | Permission Code |
|---|---|
| View users | users:read |
| Create/edit users | users:full_access |
| Assign roles | rbac:manage_roles |
| Activate/deactivate | users:cancel |
| Delete users | users:delete |
Technical Implementation
Service Layer
User management operations are handled by:userService.ts: Current user profile operationsuserAdminService.ts: Admin-level user management
Database Functions
admin_update_user_profile
Updates user profile and synchronizes metadata to Supabase Auth:
admin_reset_user_password
Resets a user’s password and records audit information:
These RPC functions may not be available in older deployments. The frontend includes backward-compatible fallback logic.
Best Practices
Use Strong Passwords
Always use the password generator (16+ characters) when creating users or resetting passwords.
Assign Roles Immediately
Users without roles have no permissions. Always assign a role during user creation.
Deactivate Instead of Delete
Prefer deactivation over deletion to preserve audit trails and historical data.
Review Location Assignments
Ensure users are assigned to the correct location for proper data access and filtering.
Troubleshooting
”No tienes permiso para crear/editar usuarios”
Cause: Missingusers:full_access permission.
Solution: Contact an administrator to grant the required permission through role assignment.
Email Already Exists
Cause: The email address is already registered in Supabase Auth. Solution: Use a different email or delete/reactivate the existing user.Password Reset Not Available
Cause: Theadmin_reset_user_password RPC function is not deployed.
Solution: Deploy the latest SQL migrations from sql/modules/ or use the Supabase dashboard to reset passwords manually.
User Cannot Log In After Creation
Possible causes:- User is marked as
is_active = false - User has no role assigned
- Email confirmation is required (check Supabase Auth settings)