Panahashi uses Firebase Authentication for secure user sessions. Auth state is managed inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/AndrewwCO/Panahashi/llms.txt
Use this file to discover all available pages before exploring further.
context/AuthContext.js and exposed through a React context, making the current user and auth actions available from any screen in the app. This page explains how account creation, sign-in, and sign-out work, and how the session state flows through the app.
Signing in and registering
AuthContext exposes three auth actions:
| Function | Firebase call | Description |
|---|---|---|
login(email, password) | signInWithEmailAndPassword | Signs in an existing user |
register(email, password) | createUserWithEmailAndPassword | Creates a new account |
logout() | signOut | Ends the current session |
login and register resolve with a Firebase UserCredential; logout resolves with void. Any Firebase error (wrong password, email already in use, etc.) is thrown and should be caught in the calling screen.
The full value shape provided by AuthContext:
Session state
AuthContext subscribes to onAuthStateChanged in a useEffect that runs once on mount:
loading starts as true and is set to false after the first callback fires. This means:
- On cold start, there is a brief window where
loadingistrueanduserisnullregardless of whether the user is actually signed in. RootNavigatoruses thisloadingflag to show anActivityIndicatorinstead of the Login screen during this window, preventing a visible flash.
Firebase persists the session to device storage automatically. You do not need to store the token or user ID yourself —
onAuthStateChanged will restore the session on the next app launch.Using auth in screens
ImportuseAuth from AuthContext and destructure the values you need:
user is the Firebase User object and includes fields like user.uid, user.email, and user.displayName. It is null when no session is active.
Firebase tokens for API calls
Authenticated API requests require a Firebase ID token. TheauthHeaders() function in services/api.js fetches the token from the current user and attaches it to every request:
X-User-Name is an additional header used by the backend for display purposes; it falls back to 'Cliente' when displayName is not set.