TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/interezante456-pixel/nuevo-proyecto-viernes/llms.txt
Use this file to discover all available pages before exploring further.
Usuario entity represents a staff member who can authenticate and operate within Tienda Mi Cholo. Each user is assigned exactly one Rol — Administrador, Gerente, or Cajero — which drives view-level and action-level authorization throughout the MVC application. The Estado flag provides a non-destructive way to revoke access without deleting the account or its associated audit trail. Both Usuario and Rol are persisted through AppDbContext (Usuarios and Roles DbSets) and their relationship is configured via Fluent API in OnModelCreating. A default administrator account and all three roles are seeded on first migration.
Usuario Properties
Primary key. Auto-generated by the database using
DatabaseGeneratedOption.Identity. Annotated with [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]. ID 1 is reserved for the seeded administrator account.The user’s full display name shown throughout the back-office UI and on printed receipts. Annotated with
[Required, StringLength(50)] — must be non-null and no longer than 50 characters.The user’s username / handle. Annotated with
[Required, StringLength(50)] — maximum 50 characters. Stored as a claim (ClaimTypes.Name) in the authentication cookie upon successful login. Used for display purposes in the navigation bar.The email address used as the login credential on the sign-in form. Annotated with
[Required, StringLength(50)] — maximum 50 characters. Must be unique across all active users; the controller performs a duplicate-check before creating or updating a record.The user’s password. Annotated with
[Required, StringLength(100)] — maximum 100 characters. Currently stored as plain text. See the Security Warning section below.Account active/inactive flag. Annotated with
[Required].true— the account is active; the user can log in and access the application.false— the account is disabled; login attempts are rejected even with the correct credentials, without exposing any error details to the user.
Estado = false over deleting a user account to preserve the integrity of Venta.Usuario_ID references in historical sales data.Foreign key to Valid values are
Rol.ID_Rol. Configured via Fluent API in AppDbContext.OnModelCreating:1 (Administrador), 2 (Gerente), or 3 (Cajero).Navigation property to the associated
Rol. Non-nullable — every Usuario must have a role. Requires .Include(u => u.Rol) to load eagerly. The Rol.NomRol string is stored as a claim (ClaimTypes.Role) in the authentication cookie on login.Usuario — C# Source
Rol Properties
Primary key. Auto-generated by the database using
DatabaseGeneratedOption.Identity. Annotated with [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]. IDs 1–3 are reserved for the three seeded roles.The human-readable role name. Annotated with
[Required, StringLength(50)] — maximum 50 characters. This value is written into ClaimTypes.Role when the user authenticates, and is therefore used directly in [Authorize(Roles = "...")] decorators across the controllers.Inverse navigation collection of all
Usuario records assigned to this role. Non-nullable collection (though it may be empty). Requires .Include(r => r.Usuarios) to load eagerly.Rol — C# Source
Security Warning
Seeded Roles
Three roles are created byAppDbContext.OnModelCreating via HasData and are always present after the initial migration:
| ID_Rol | NomRol | Typical Permissions |
|---|---|---|
1 | Administrador | Full access — user management, role assignment, reports, product/category CRUD. |
2 | Gerente | Inventory management, reports, product/category CRUD; cannot manage user accounts. |
3 | Cajero | POS sales entry and receipt printing only; read-only access to product catalogue. |
The seeded administrator account (
ID_Usuario = 1, NomUsuario = "admin", CorreoUsuario = "admin@micholo.com") is assigned Rol_ID = 1 (Administrador). Change its password immediately after the first successful migration in any non-development environment.