profiles table stores user information and role-based permissions. It extends Supabase Auth with custom user data.
Table Name
profiles
This table is typically created via Supabase Auth triggers and stores additional user metadata beyond authentication credentials.
Schema Fields
Primary key, matches the Supabase Auth user ID
User’s email address, synced from Supabase Auth
User’s full display name
User role for access controlAllowed values:
guest- Hotel guest with temporary accessempleado- Staff member (employee)admin- Administrator
Department/area assignment for staff members. Only applicable for
empleado role.Should match a value from the areas table name field.Automatically set when the profile is created
Relationships
- incidents: One-to-many relationship via
assigned_tofield - incident_resolutions: One-to-many relationship via
resolved_byfield - areas: Logical relationship via
areafield (string match onareas.name)
Role Descriptions
Temporary users who report incidents through guest sessions. Guests:
- Access the app via QR codes or access codes
- Can create and view their own incidents
- Have limited permissions tied to their room
- Don’t appear in the admin users list (filtered by
role != "guest")
Hotel staff members assigned to specific areas. Employees:
- View incidents for their assigned area
- Can accept and resolve incidents
- Must have an
areavalue assigned - Track their task assignments
System administrators with full access. Admins:
- Manage all users and incidents
- Create guest sessions
- Assign staff to areas
- Access all system features
Query Examples
Fetch User Profile
Retrieve the current user’s profile:mobile/app/(admin)/_layout.tsx:15
List All Staff Members
Fetch all users excluding guests:mobile/app/(admin)/users.tsx:47
Get User by Area
Find staff members assigned to a specific area:mobile/components/EmpleadoBuzonIncidents.tsx:191
Create or Update User Profile
Upsert a user profile (used during user creation):mobile/components/settings/admin/CreateUserModal.tsx:86
Update User Profile
Modify existing user information:mobile/components/settings/admin/EditUserModal.tsx:75
Delete User
mobile/app/(admin)/users.tsx:86
Area Assignment
Staff members (empleados) are assigned to specific areas to determine which incidents they can see and handle:mobile/components/EmpleadoBuzonIncidents.tsx:191
User Interface Example
In the admin UI, user cards display:mobile/app/(admin)/users.tsx:23
Security Considerations
Related Tables
Incidents
Incidents assigned to staff members
Areas
Department assignments
Incident Resolutions
Resolutions created by staff