Overview
The Access Request system allows new users to register and request access to the CEDIS Pedidos platform. Administrators review these requests and approve or reject them based on organizational policies.All access requests start in a
pendiente (pending) state and require explicit admin approval before users can log in.Access Request Structure
Each access request contains:src/lib/types.ts:41-53
Database Schema
supabase/add_auth_access_control.sql:14-26
Accessing Access Requests
Open Solicitudes Tab
Click the Solicitudes & Usuarios tab. A badge shows the count of pending requests.
Pending Request Badge
The tab displays a notification badge when there are pending requests:src/pages/Dashboard.tsx:119-122 and src/components/admin/SolicitudesPanel.tsx:180-183
Reviewing Access Requests
Fetching Requests
Requests are loaded with branch information:src/components/admin/SolicitudesPanel.tsx:42-45
Request Card Display
Each pending request shows:- Name (
nombre) - Email (
email) - Requested Branch (
sucursal.nombre) - Message (
mensaje) - optional note from the user - Submission Date (
created_at)
src/components/admin/SolicitudesPanel.tsx:215-231
Approving Access Requests
Review Request Details
Check the user’s name, email, requested branch, and any message they provided.
Approval Logic
src/components/admin/SolicitudesPanel.tsx:65-74
Approving a request sets the user’s
estado_cuenta to activo, allowing them to log in immediately.Rejecting Access Requests
Identify Invalid Request
Determine if the request should be denied (e.g., invalid email domain, unauthorized user).
Rejection Logic
src/components/admin/SolicitudesPanel.tsx:77-86
Request States
Access requests can be in one of three states:Awaiting admin review. Displayed prominently in the pending section.
Request approved. User can access the system. Moved to history.
Request rejected. User account is inactive. Moved to history.
Visual Indicators
src/components/admin/SolicitudesPanel.tsx:150-154
Request History
Reviewed requests (approved or rejected) are moved to a collapsible history section:src/components/admin/SolicitudesPanel.tsx:248-269
The history section preserves audit trails showing who was approved/rejected and when.
Row-Level Security
Access request policies:supabase/add_auth_access_control.sql:32-46
Pending Request Counter
The system tracks pending requests to show notification badges:src/pages/Dashboard.tsx:58-62
User Registration Flow
User Self-Registers
New user fills out registration form with name, email, branch selection, and optional message.
Request Created
A
solicitudes_acceso record is created with estado = 'pendiente'.A corresponding users record is created with estado_cuenta = 'pendiente'.Admin Reviews
Administrator receives notification (badge count increases).Admin reviews request details in the Solicitudes panel.
Best Practices
Review Criteria
- Email Domain: Verify the email belongs to authorized domains (e.g.,
@clorodehidalgo.com) - Branch Assignment: Confirm the requested branch is appropriate
- Message Review: Read any message from the user for context
- Duplicate Checks: Ensure no duplicate accounts for the same person
Timely Processing
Process access requests promptly to avoid blocking new users. Aim to review within 24 hours.
Communication
If rejecting a request:- Note the reason internally
- Consider reaching out to the user via email to explain why (external to the system)
Troubleshooting
Request Shows user_id = null
Cause: The user account may not have been created properly during registration. Solution: This is an edge case. Verify theusers table has a corresponding record. May require manual SQL intervention.
Cannot Approve or Reject
Cause: User may not haveadmin role.
Solution: Verify your account has rol = 'admin' in the users table:
User Still Cannot Log In After Approval
Cause: Theusers.estado_cuenta may not have updated.
Solution: Manually verify and update:
Data Cleanup
Periodically archive old requests:Related Sections
User Management
Manage approved users and their permissions
Branch Management
Configure branches that users request access to