Ecommerce Delivery enforces access control through a role system stored on the authenticated user object. Each user carries aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/ecommerce-delivery-frontend/llms.txt
Use this file to discover all available pages before exploring further.
roles array containing one or more role entries, and the validateUser utility in src/tools/User.js checks those roles on both navigation and before protected API calls. Understanding the three roles and how they are evaluated is key to working with any feature that restricts content by user type.
Roles
| Role Name | Value | Access Level |
|---|---|---|
usuario | 1 | Browse the store, add items to cart, place orders, view own purchase history |
admin | 2 | Full access — product CRUD, sales reports, member management, delivery status updates |
promotor | 3 | Same as usuario, plus access to the Shopping List (/shoppingList) |
How roles are checked
ThevalidateUser function from src/tools/User.js is the single source of truth for all client-side role checks. It accepts a data object with a rol property that can be either a single role value or an array of values.
roles array has value == 2, the check passes unconditionally — admins always have access regardless of what data.rol specifies.
Single role check — require a specific role:
validateUser returns false, the calling component typically redirects to /login or shows an unauthorized notification.
Role-gated UI example
The main store page (pages/store/MainStore.vue) uses the dataUser object returned by getDataUser() to conditionally render the Agregar (Add Product) button. Only users whose roles array contains an entry with value == 2 see the button:
getDataUser() once to bind the user object to reactive state, then call validateUser({ rol }) before every network request — is used consistently across the application.
Stored role format
Roles are stored inside the user object as an array of objects, each with aname string and a value string (numeric value as a string):
promotor would have [{ "name": "promotor", "value": "3" }]. The validateUser function coerces value to Number before comparison, so both "3" and 3 are treated equally.
