BodegaX operates on a straightforward two-role model —Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Edwin950821/BodegaX/llms.txt
Use this file to discover all available pages before exploring further.
admin and user — where the role value is established at login, persisted in the browser’s session storage, and then propagated reactively throughout every component via AppService. Route guards prevent unauthenticated access entirely, while *ngIf bindings driven by the live role$ observable ensure each role sees only the UI elements relevant to their responsibilities in the warehouse.
How Roles Are Stored
When a user authenticates, the Spring Boot backend returns a session object that includes arole field. AppService.logIn() serialises this object into sessionStorage under the key "bodegax":
sessionStorage['bodegax'] and restores both the logged-in state and the role before any component renders:
The AppService Reactive State Pattern
AppService uses RxJS BehaviorSubject to hold the pieces of global state that all components share. Components and guards never read sessionStorage directly — they subscribe to the public observable getters instead.
The
isLogged BehaviorSubject is initialised to true at declaration time, but the AppService constructor immediately overrides it based on the actual contents of sessionStorage. The initial true value is never visible to subscribers because the constructor runs synchronously before any subscription can occur.Route Guards
BodegaX ships two Angular route guards that useisLogged$ to protect the application’s route tree.
CheckLoginGuard
Applied to protected routes such as
/ and /settings. If isLogged$ emits false, the guard navigates to /login and returns false, blocking the route. Authenticated users pass through and receive true.CheckNotLoginGuard
Applied to
/login. If isLogged$ emits true (user is already authenticated), the guard redirects to / and returns false. Unauthenticated visitors receive true and can access the login page normally.CheckLoginGuard Implementation
CheckNotLoginGuard Implementation
Role-Based Feature Matrix
Components subscribe torole$ and use Angular’s *ngIf directive to conditionally render UI elements. The table below maps each major feature to the role that can access it.
| Feature | Admin (admin) | User (user) |
|---|---|---|
View Settings page (/settings) | ✅ | ❌ |
| Create / edit / delete users | ✅ | ❌ |
| Terminar Jornada (close the workday) | ✅ | ❌ |
| View all clients’ order history | ✅ | ❌ |
| Solicitar Caja (request a crate) | ❌ | ✅ |
| View own history | ❌ | ✅ |
Self-register at /register | ✅ | ✅ |
| View inventory / product listing | ✅ | ✅ |
Example Conditional Rendering
A typical admin-only button in a BodegaX template looks like:role$ during initialisation and stores the emitted value in a local property:
Role Assignment Rules
How is the admin role assigned?
How is the admin role assigned?
There is no in-app UI to elevate a
user account to admin. The role must be set directly in the PostgreSQL database (by updating the role column on the relevant row in the users table) or via a backend-level script or migration. BodegaX does not expose an admin-promotion endpoint in the current version.What role does a self-registered user receive?
What role does a self-registered user receive?
Every account created through
/register or the Settings page dialog receives role: 'user' — it is hard-coded in the POST /admin/create request body on the frontend. There is no way to self-register as an admin.What happens if the session is tampered with?
What happens if the session is tampered with?
Because
sessionStorage is client-side, a technically sophisticated user could manually edit the role field in sessionStorage['bodegax']. However, all sensitive backend endpoints should validate the role from the JWT or server-side session — the Angular role check is a UI convenience, not a security boundary. Ensure your Spring Boot controllers enforce role-based access control independently.New users created via
/register always receive role='user' by default. To grant admin privileges, the role field must be updated directly in the PostgreSQL database or through a dedicated backend operation — there is no in-app promotion workflow in the current version of BodegaX.