Documentation Index
Fetch the complete documentation index at: https://mintlify.com/AdriP-maker/JAAR_Antigravity/llms.txt
Use this file to discover all available pages before exploring further.
authService wraps Supabase Auth and provides a session abstraction layer for SIMAP Digital. After a successful login it stores a lightweight session object in sessionStorage, triggers an offline sync of all resident and payment data, and exposes route-guard helpers that enforce role-based access control (RBAC) across the application.
Session object
The session is stored in
sessionStorage under the key 'simap_session' as a JSON string. It is cleared on logout() and does not persist across browser tab closures.The authenticated user’s email address.
Role assigned to this user:
'admin' | 'cobrador' | 'minsa' | 'cliente' | 'dev'. Falls back to 'cliente' if no profiles row is found at login time. Note: the on_auth_user_created trigger inserts new profiles with rol: 'user' by default — administrators must update this to an application role before the user can log in successfully.Display name from the Supabase
profiles table. Falls back to the email address.The Supabase Auth UUID for this user.
ISO 8601 timestamp of when the session was created.
login(email, password)
Authenticates a user against Supabase, loads their profile, enforces account-state checks, persists the session in sessionStorage, and kicks off an offline data sync.
User’s email address. Leading and trailing whitespace is trimmed before the Supabase call.
User’s plain-text password. Sent directly to
supabase.auth.signInWithPassword.true on successful authentication; false on any failure.Populated only when
success is true. Contains the full session object (see above).Populated only when
success is false. Human-readable Spanish error message.login reads the user’s profiles row and rejects login for:
profile.estado | Error message |
|---|---|
'pendiente' | '⏳ Tu cuenta aún no ha sido aprobada.' |
'rechazado' | '❌ Tu solicitud fue rechazada.' |
'suspendido' | '⚠️ Tu cuenta ha sido suspendida.' |
logout()
Signs the user out of Supabase, removes the session from sessionStorage, and wipes the three core Dexie tables (usuarios, pagos, saldos) to prevent data leakage between sessions.
void. Resolves once Supabase sign-out and all Dexie table clears are complete.
Example
getSession()
Parses and returns the current session object from sessionStorage.
Session object (see Session object) if a valid session exists, or null if no session is stored or parsing fails.
Example
isAuthenticated()
Convenience helper that returns true when a valid session exists in sessionStorage.
true if getSession() returns a non-null value; false otherwise.
Example
getHomeRoute(role)
Returns the default home route for a given role, as defined in the ROLE_HOME constant.
A role string:
'admin' | 'cobrador' | 'minsa' | 'cliente' | 'dev'.'/login' if the role is unrecognized.
| Role | Home route |
|---|---|
admin | /admin |
cobrador | /cobros |
minsa | /reporte |
cliente | /historial |
dev | /admin |
isRouteAllowed(role, path)
Checks whether a given role has permission to access a route. Used by the router’s navigation guard to enforce RBAC on every page transition.
The authenticated user’s role string.
The target route path (e.g.,
'/cobros', '/admin/usuarios'). Matching uses String.startsWith, so /admin grants access to /admin/usuarios and all sub-paths.true if the role’s allowed-routes list contains a prefix that matches path; false otherwise.
Rules object
registerUser({ email, pass, nombre, sector })
Registers a new resident (cliente) account via Supabase Auth signUp, embedding nombre and sector as user metadata for profile creation.
New user’s email address. Trimmed before the Supabase call.
Plain-text password for the new account.
Resident’s full name or household name (e.g.,
'Familia Moreno'). Stored as Supabase user metadata.Resident’s sector or neighborhood (e.g.,
'Caballero Centro'). Stored as Supabase user metadata and used by recoverByHouse.true if Supabase signup completed without errors.Populated only on failure. Contains the raw Supabase error message.
New accounts are created with
estado: 'pendiente' in the Supabase profiles table and must be approved by an administrator before the resident can log in.recoverByHouse(casa)
Looks up a resident’s account by their sector name. Useful for helping residents who have forgotten their email address.
Sector or neighborhood name to search by (e.g.,
'Caballero Abajo'). Performs an exact-match query on the Supabase profiles.sector column.null if no profile matches the sector.
The resident’s registered email address.
The resident’s display name.
registerJunta({ nombre_junta, ruc, admin_user, pass, email })
Registers a new water board (junta) and its administrator account in a single operation. Creates a Supabase Auth user with the 'admin' role and inserts a new row into the juntas table with estado: 'pendiente_global' pending global platform approval.
Official name of the water board (e.g.,
'Junta de Agua Caballero'). Stored as Supabase user metadata nombre and inserted into juntas.nombre.RUC (Registro Único de Contribuyente) — the board’s tax identification number. Stored in
juntas.ruc.Username or email for the board’s admin account. Used as the Supabase Auth email if
email is not provided (trimmed before use).Password for the admin account.
Optional explicit email address. If provided, takes precedence over
admin_user as the Supabase Auth email.true if both the Auth user and the juntas record were created successfully.Populated on failure. Returns the Supabase error message from whichever step failed (Auth signup or junta insert).
Newly registered juntas receive
estado: 'pendiente_global' and must be approved by the SIMAP platform administrator before their admin can log in and configure board settings.