Login route
The login page is served at/login. Unauthenticated users are redirected here automatically by the authGuard.
Authentication flow
Open the login page
Navigate to
/login. If you are already authenticated, loginGuard redirects you to /dashboard (or the returnUrl query parameter if one is present).Submit your credentials
Enter your email address and password in the Login form and click Entrar al Sistema.The panel sends a The request body matches the
POST request to /api/auth/login:LoginPayload interface:Receive the JWT response
On success the API returns a The
LoginResponse object:user field is an AuthUser:Role validation
Before storing anything, the panel checks that
user.rol is one of the four allowed values: ADMIN, MESA, AREA, or USUARIO. If the role is missing or unrecognised, the login is rejected and logout() clears any partial state.Token and user stored locally
After a successful role check, the panel writes two entries to
localStorage:| Key | Value |
|---|---|
admin_token | The raw JWT string from access_token |
admin_user | JSON-serialised AuthUser object |
The token is stored in
localStorage, not in a cookie. This means it persists across page refreshes and browser restarts until you explicitly log out.Route guards
authGuard
All routes under the main layout are protected by authGuard. It checks localStorage for admin_token. If no token is found, it redirects to /login and appends the originally requested URL as a returnUrl query parameter:
loginGuard
The /login route is protected by loginGuard. If you are already logged in, it redirects you away from the login page—either to the returnUrl query parameter or to /dashboard:
HTTP interceptor
TheauthInterceptor runs on every outgoing HTTP request. It reads admin_token from localStorage and attaches it as an Authorization header:
/api/auth/login are excluded — the login endpoint does not require a token.