Host account setup
Hosts authenticate through Firebase, manage content from the dashboard, and share a simple join code with players. Use this guide to verify access and keep credentials secure.
Create or sign in to your host account
Host tools live behind the `/login` route and use Firebase Authentication.
- Visit `/login` and pick either Google sign-in or email + password. Both methods land you in the host dashboard once authentication succeeds.
- If you register with email, verify the confirmation message Google/Firebase sends before trying to sign in again.
- Forgotten password? Use the reset link on the login form – Avalanche sends a Firebase password-reset email immediately.
- Hosts can choose where to go after login by adding `?next=/host/games` (or any other host path) to the login URL.
Tip: Keep a dedicated host account even if you sometimes play. Player sessions do not require authentication and share the same browser storage keys.
Confirm dashboard access
After authentication you should see the Host navigation shell and the default Account view.
- Check the sidebar – links for Account, Profile, Games, Question Sets, Analytics, and Support indicate you have the required permissions (see `src/components/host/HostNavigation.tsx`).
- Open Question Sets to ensure Firestore permissions allow you to list and create documents. A toast error here usually means the signed-in email has not been whitelisted.
- Navigate to Games and confirm you can start a new game. When creation succeeds, the console logs the generated code and you are redirected to `/host/games/{code}`.
- Load the host account page to verify billing and profile data read correctly; empty placeholders suggest the Firestore document has not been created yet.
Tip: If any host page immediately redirects you back to `/login`, check the browser console for `permission-denied` – you may be signed into the wrong Firebase project.
Understand player access
Players never need to sign in. They only require the lobby code generated when you start a game.
- Share the six-character code (e.g. `ABX421`) or the full join URL (`/join?code=ABX421`).
- Players enter a display name on the join screen; Avalanche stores their player ID, game ID, and code in `localStorage` so reconnects are seamless.
- Player accounts live under `games/{gameId}/players/{playerId}`. Removing a document from this collection immediately removes the player from the lobby.
- If a player appears twice (usually after reconnecting on a new device), delete the older record in the lobby list from the host dashboard.
Tip: Remind players to keep the join tab open while they wait. The waiting room video confirms the Firestore listener is still active.
Lock down your host credentials
Avalanche relies on Firebase for authentication, so apply the same safeguards you would for any Google-backed project.
- Use a password manager or passkey for email/password accounts; Firebase rejects common or compromised passwords by default but you should still rotate them periodically.
- Enable multi-factor authentication for your Google account if you use Google sign-in. The host dashboard has no secondary approval, so your Google login is the gatekeeper.
- Limit who can read/write host collections in Firestore security rules (`/firestore.rules`). The default project rules already scope writes to authenticated users – keep them that way.
- Avoid sharing raw service-account keys. Every action the dashboard performs runs through the browser SDK and respects the signed-in user permissions.
Tip: When testing locally with different accounts, use separate Chrome profiles so each session keeps its own Firebase auth state and local storage entries.
Troubleshooting
Login loops back to the sign-in screen
- Clear `localStorage` keys starting with `firebase:authUser` and retry.
- Make sure the project's authorised domain list includes the hostname you are using (Firebase console → Authentication → Settings).
- Inspect the network tab for `permission-denied` responses – they usually mean your user record is missing the `role: 'host'` flag in Firestore.
Cannot create or list question sets
- Check whether you are signed into the correct Firebase project. Question sets read from `questionSets` – the collection must exist in the same project as the site.
- Verify the Firestore rules still mirror `firestore.rules` in the repo. A stale deploy can block writes for authenticated users.
- Watch the console for `firestore/permission-denied` after clicking Create. If it appears, re-run deployment of rules or update the user role document.
Players report the join code is invalid
- Double-check that you shared the game code rather than the document ID – the join page accepts the uppercase six-character code only.
- Confirm the game status is still `waiting`, `lobby`, `active`, or `paused`. Finished games reject new joins.
- If you deleted the game document from Firestore, create a new one and share the replacement code.