AgroPulse uses Google OAuth through Supabase as its only sign-in method. There are no passwords to manage — your Google account is your identity. Once authenticated, the app determines your role and which greenhouses you can access before letting you into the dashboard.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/diarpicu2022-commits/frontend-AgroPulse/llms.txt
Use this file to discover all available pages before exploring further.
Signing in
On the login page, click the Google tab and then Continue with Google. Supabase opens a Google OAuth consent screen. After you approve, Google redirects you back to AgroPulse and your session is established. The app immediately calls the backend to register your account (first visit) or retrieve your existing profile. Your Google display name and profile photo are pulled from the OAuth metadata and used throughout the interface.The first sign-in of the day may take a few extra seconds if the backend has gone to sleep on Render’s free hosting tier. The app sets an 8-second timeout on the backend call. If the server doesn’t respond in time, it falls back to a local session using the data cached in your browser, then retries in the background once the server wakes up. Your session is valid either way.
User roles
AgroPulse has two roles. Your role determines what you can see and do in the dashboard.- Admin
- Operator
Admins have unrestricted access to every feature and every greenhouse in the system.What admins can do:
- View and manage all greenhouses
- Register and configure sensors, actuators, and ESP32 devices
- Create and edit crops, automation rules, and alert thresholds
- Access Logs, Users, Roles, and Support pages under Administration
- Assign greenhouse access to operators
- Configure AI provider keys in Settings
- Generate reports and view all analytics
allowedGreenhouseIds value is null, which the app treats as “all access.” Admin status is determined by the ADMIN role flag returned by the backend, or — as a fallback during cold-start — by whether the email address matches the admin account or contains the word admin.Greenhouse access for operators
When an operator logs in, the app fetches their assigned greenhouse IDs from the backend. If the list is empty, they land on the No Access page after an 8-second wait.How access is assigned
How access is assigned
Only admins can assign greenhouse access. In the AgroPulse dashboard, go to Administration → Roles and select the operator’s account. From there you can add or remove greenhouses from their access list.The assignment is stored in the backend database. The next time the operator signs in — or when they click Retry on the No Access page — the app fetches the updated list.
How operators can refresh their access
How operators can refresh their access
If an admin has just granted you access and you’re still on the No Access screen, click the Retry button. This triggers
refreshAccess, which works in three stages:- Direct lookup by user ID — the fastest path. The app calls
GET /api/users/{id}/greenhousesto get the current list. - Re-authentication — if the direct lookup fails (for example, if the backend was briefly offline and your user ID wasn’t confirmed yet), the app calls
POST /api/auth/loginwith your Google email to fetch both your confirmed user ID and greenhouse list in one request. - Local cache — if both network calls fail, the app checks browser localStorage for any previously cached assignments. This is a last resort and only used if there’s a cached value; it will not overwrite valid state with an empty result.
Why there's an 8-second wait before the No Access page
Why there's an 8-second wait before the No Access page
When the backend is starting up (cold-start on Render), the login API call may time out before returning the greenhouse list. Rather than immediately showing a No Access page to a legitimate user whose access just hasn’t loaded yet, the app waits up to 8 seconds for the
allowedGreenhouseIds to be populated. After 8 seconds with no data, it shows the No Access page with a Retry button.Session persistence
AgroPulse uses Supabase’s built-in session management. Your Google session token is stored in the browser and automatically refreshed by Supabase. When you return to the app,getSession() is called on load — if a valid session exists, you’re signed in immediately without going through the Google OAuth flow again.
Profile data (avatar URL and display name) is cached in localStorage under the key agropulse_profile_cache keyed by email. This cache is used to display your profile while the backend loads, and is updated whenever you sign in or save profile changes.
Profile management
You can update your display name and profile photo from Settings → My Profile.- Display name — enter a new name and click Save changes. The name is saved to the backend and updated in the local cache.
- Profile photo — paste a URL or upload an image file (max 1 MB). The photo is saved to the backend and cached locally in localStorage.
Your Google profile photo is applied automatically on every sign-in and overrides any locally set photo. If you want a custom avatar to persist, save it via the Settings profile editor — the app merges your saved avatar with your Google metadata.
Signing out
Click Sign out (Cerrar sesión) at the bottom of the sidebar or at the bottom of the Settings page. This clears your local session state and callssupabase.auth.signOut() to invalidate the Supabase token.