Conversation
isAuthenticated, rename isLoggedIn to isAuthenticated (@copilot)
There was a problem hiding this comment.
Pull request overview
Consolidates frontend auth checks by removing Firebase’s isAuthenticated() and renaming the reactive states/core.isLoggedIn() helper to states/core.isAuthenticated(), updating call sites to use the reactive state as the canonical source.
Changes:
- Rename
isLoggedIn→isAuthenticatedinstates/core.ts. - Remove
isAuthenticatedexport fromfirebase.ts. - Update call sites (UI, commandline, DB, queries, tests) to import
isAuthenticatedfromstates/core.
Reviewed changes
Copilot reviewed 37 out of 37 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/ts/states/core.ts | Renames reactive auth helper to isAuthenticated() (based on getUserId()). |
| frontend/src/ts/firebase.ts | Removes isAuthenticated() export; relies on userId signal elsewhere. |
| frontend/src/ts/auth.tsx | Switches isAuthenticated import to states/core. |
| frontend/src/ts/commandline/lists.ts | Switches isAuthenticated import; affects sign-out command availability. |
| frontend/src/ts/commandline/commandline-metadata.ts | Routes auth check usage to states/core. |
| frontend/src/ts/commandline/lists/navigation.ts | Uses states/core.isAuthenticated for nav decisions. |
| frontend/src/ts/commandline/lists/custom-themes-list.ts | Uses states/core.isAuthenticated for command availability/guards. |
| frontend/src/ts/commandline/lists/presets.ts | Uses states/core.isAuthenticated for command availability/guards. |
| frontend/src/ts/commandline/lists/quote-favorites.ts | Uses states/core.isAuthenticated for command availability/guards. |
| frontend/src/ts/commandline/lists/tags.ts | Uses states/core.isAuthenticated for command availability/guards. |
| frontend/src/ts/controllers/route-controller.ts | Uses states/core.isAuthenticated for routing/auth gating. |
| frontend/src/ts/db.ts | Uses states/core.isAuthenticated to gate user-specific DB operations. |
| frontend/src/ts/config/metadata.ts | Uses states/core.isAuthenticated to gate config behaviors requiring login. |
| frontend/src/ts/queries/index.ts | Reacts to auth changes via createEffectOn(isAuthenticated, ...). |
| frontend/src/ts/collections/inbox.ts | Uses states/core.isAuthenticated to gate live inbox query. |
| frontend/src/ts/pages/settings.ts | Uses states/core.isAuthenticated for settings behaviors. |
| frontend/src/ts/pages/account-settings.ts | Uses states/core.isAuthenticated for account settings gating. |
| frontend/src/ts/pages/settings.ts | Consolidates auth checks to states/core. |
| frontend/src/ts/modals/simple-modals.ts | Uses states/core.isAuthenticated for modal action guards. |
| frontend/src/ts/modals/user-report.ts | Uses states/core.isAuthenticated for report gating. |
| frontend/src/ts/event-handlers/account.ts | Uses states/core.isAuthenticated for account event guards. |
| frontend/src/ts/elements/modes-notice.ts | Uses states/core.isAuthenticated for UX messaging logic. |
| frontend/src/ts/elements/settings/theme-picker.ts | Uses states/core.isAuthenticated for theme persistence logic. |
| frontend/src/ts/elements/account-settings/blocked-user-table.ts | Uses states/core.isAuthenticated for table actions. |
| frontend/src/ts/elements/account-settings/ape-key-table.ts | Uses states/core.isAuthenticated for key editing actions. |
| frontend/src/ts/components/pages/test/TestConfig.tsx | Uses states/core.isAuthenticated for conditional UI. |
| frontend/src/ts/components/pages/profile/UserDetails.tsx | Uses states/core.isAuthenticated for conditional profile actions. |
| frontend/src/ts/components/pages/leaderboard/Sidebar.tsx | Uses states/core.isAuthenticated for friends-only toggle visibility. |
| frontend/src/ts/components/pages/leaderboard/LeaderboardPage.tsx | Uses states/core.isAuthenticated for query enablement/rendering. |
| frontend/src/ts/components/modals/QuoteSearchModal.tsx | Uses states/core.isAuthenticated for favorites/submit UI. |
| frontend/src/ts/components/modals/MobileTestConfigModal.tsx | Uses states/core.isAuthenticated for login-required options. |
| frontend/src/ts/components/layout/footer/ThemeIndicator.tsx | Uses states/core.isAuthenticated for indicator logic. |
| frontend/src/ts/components/common/anime/AnimeConditional.tsx | Updates doc example to isAuthenticated(). |
| frontend/src/ts/test/test-logic.ts | Uses states/core.isAuthenticated instead of Firebase export. |
| frontend/src/ts/test/result.ts | Uses states/core.isAuthenticated instead of Firebase export. |
| frontend/src/ts/test/test-screenshot.ts | Uses states/core.isAuthenticated instead of Firebase export. |
| frontend/src/ts/ape/config.ts | Uses states/core.isAuthenticated for API/config logic gating. |
| frontend/tests/harness/mock-firebase.ts | Removes defunct isAuthenticated mock export. |
| } from "./firebase"; | ||
| import * as Sentry from "./sentry"; | ||
| import { isAuthenticated } from "./states/core"; |
There was a problem hiding this comment.
auth.signOut() now relies on states/core.isAuthenticated() (userId signal). During Google/GitHub new-user signup flows ignoreAuthCallback prevents setUserId, so isAuthenticated() stays false even though Firebase currentUser exists; this makes signOut() a no-op and can leave the user signed in after cancelling/failing signup. Fix by basing the guard on getAuthenticatedUser() !== null (or just calling authSignOut() whenever isAuthAvailable()), rather than the reactive userId state.
| import { CommandlineConfigMetadataObject } from "./commandline-metadata"; | ||
| import { isAuthAvailable, isAuthenticated, signOut } from "../firebase"; | ||
| import { isAuthAvailable, signOut } from "../firebase"; | ||
| import { isAuthenticated } from "../states/core"; |
There was a problem hiding this comment.
The commandline signOut command availability now depends on states/core.isAuthenticated(). In flows where Firebase has a currentUser but the app intentionally hasn't set userId yet (e.g. new-user OAuth signup with ignoreAuthCallback), this hides the Sign out command and prevents recovery. Use getAuthenticatedUser() !== null (or remove the isAuthenticated() check) for this command’s available() predicate.
| import { isAuthenticated } from "../states/core"; |
Description
Two overlapping auth-check functions existed:
firebase.isAuthenticated()(checkedAuth.currentUser) andstates/core.isLoggedIn()(checked reactivegetUserId()signal). Consolidating to one canonical function backed by the reactive state.Changes:
states/core.ts: renamedisLoggedIn→isAuthenticatedfirebase.ts: removedisAuthenticatedexportisAuthenticatedfromstates/coreinstead offirebasemock-firebase.ts: removed now-defunctisAuthenticatedmock entryChecks
packages/schemas/src/languages.tsfrontend/src/ts/constants/languages.tsfrontend/static/languagespackages/schemas/src/themes.tsfrontend/src/ts/constants/themes.tsfrontend/static/themespackages/schemas/src/layouts.tsfrontend/static/layoutsfrontend/static/webfontspackages/schemas/src/fonts.tsfrontend/src/ts/constants/fonts.tsWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
iojs.org/usr/bin/curl curl -q --fail --compressed -L -s REDACTED -o - che/node-gyp/24.-c(dns block)/usr/bin/curl curl -q --fail --compressed -L -s REDACTED -o - --global de/node/bin/sh make tage�� -C build cal/share/pnpm/./home/REDACTED/work/monkeytype/monkeytype/frontend/src/ts/collections/inbox.ts 4 --global ules/.bin/uname uname(dns block)/usr/bin/curl curl -q --fail --compressed -L -s REDACTED -o - k/monkeytype/monrev-parse k/monkeytype/monHEAD k/monkeytype/monkeytype/frontend/src/ts/componenstash k/mo�� d/src/ts/commandline/lists.ts k/monkeytype/monkeytype/frontend/src/ts/componen--message e_modules/.bin/node che/node-gyp/24.git(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.