Workflow Overview
The workflow involves three main parties: the business applicant, the admin, and the system’s automated processes.
Step 1: Business Registration Request
Businesses begin by submitting an application through the public registration form.Application Data
SolicitudEmpresa.php:14-25
Submission Process
Fill Application Form
Business provides:
- Company name and contact email
- NIT (tax ID), phone, and address
- Business description
- Logo image (max 2MB: jpeg, png, jpg, webp)
- Storefront photo (max 4MB: jpeg, png, jpg, webp)
Upload Images
Images are stored temporarily in the
solicitudes/ directory:- Logo:
storage/solicitudes/logos/ - Storefront:
storage/solicitudes/locales/
API Response
At this stage, no user account is created yet. The application waits for admin review.
Step 2: Admin Review
Administrators review pending applications from their dashboard.Viewing Pending Applications
estado = 'pendiente':
AdminController.php:34
Admin Decision Points
- Approve
- Reject
Action:
POST /api/admin/aprobar/{id}When approved:- Generate a secure 60-character token
- Update application status to
aprobado - Store the token in the database
- Send activation email to the business
AdminController.php:43-54
The business receives an email with a unique activation link valid for their application.
Step 3: Email Activation
Approved businesses receive an activation email with a unique link.Email Contents
- Subject: Account approval notification
- Body: Welcome message and activation instructions
- Link:
http://localhost:5173/empresa/activar/{token}
The token in the URL is a 60-character random string that serves as a one-time activation key.
Token Validation
When the business clicks the link:EmpresaActivacionController.php:20-35
If valid, the frontend displays the activation form pre-filled with business details.
Step 4: Account Activation
The business completes activation by setting their password.Activation Process
Database Transaction
The system performs several operations atomically:a) Create User Accountb) Move Images to Permanent Storaged) Update Application Statuse) Clean Up Temporary Files
EmpresaActivacionController.php:64-70
- Logo:
solicitudes/logos/→empresas/logos/ - Photo:
solicitudes/locales/→empresas/locales/
EmpresaActivacionController.php:108-109
EmpresaActivacionController.php:112-115
EmpresaActivacionController.php:118-119
Success Response
The business is now fully registered and can log in using their email and password.
Application States
Theestado field tracks the application’s progress:
pendiente
pendiente
Initial state after form submission
- Application awaits admin review
- Visible in admin dashboard
- No user account exists yet
aprobado
aprobado
After admin approval
- Activation email sent
- Token generated and stored
- Awaiting business activation
rechazado
rechazado
After admin rejection
- Application denied
- No further action taken
- Record kept for audit purposes
completada
completada
After successful activation
- User and Empresa records created
- Token invalidated (set to null)
- Images moved to permanent storage
- Business can now log in
Post-Activation: Business Setup
Once activated, businesses gain access to their dashboard and can:Update Profile
Modify business information, logo, and photos via:
Add Products
Create their product catalog:
Set Availability
Toggle open/closed status:
Receive Orders
View and fulfill customer orders:
Key Relationships
User ↔ Empresa
Each business has one user account and one empresa profile:User.php:29-32
Empresa.php:47-50
Database Schema
Error Handling
Invalid Token
Problem: Token doesn’t exist or was already usedDuplicate Email
Problem: Email already registered inusers table
Email Delivery Failure
Problem: Mail server error during approvalAdminController.php:67-73
Security Considerations
Security Features
- One-time tokens: 60-character random strings, invalidated after use
- Email verification: Ensures applicant owns the email address
- Admin approval: Prevents automated spam registrations
- Password hashing: Passwords stored using bcrypt
- Transaction safety: Database rollback on any activation failure
Workflow Diagram with Code References
Testing the Workflow
Next Steps
User Roles
Learn about business permissions and capabilities
Order Lifecycle
Understand how businesses fulfill customer orders