Skip to content

refactor: remove firebase isAuthenticated, rename isLoggedIn to isAuthenticated (@copilot)#7738

Merged
Miodec merged 4 commits intomasterfrom
copilot/remove-isauthenticated-rename-isloggedin
Mar 30, 2026
Merged

refactor: remove firebase isAuthenticated, rename isLoggedIn to isAuthenticated (@copilot)#7738
Miodec merged 4 commits intomasterfrom
copilot/remove-isauthenticated-rename-isloggedin

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

Description

Two overlapping auth-check functions existed: firebase.isAuthenticated() (checked Auth.currentUser) and states/core.isLoggedIn() (checked reactive getUserId() signal). Consolidating to one canonical function backed by the reactive state.

Changes:

  • states/core.ts: renamed isLoggedInisAuthenticated
  • firebase.ts: removed isAuthenticated export
  • All ~35 call-sites updated to import isAuthenticated from states/core instead of firebase
  • mock-firebase.ts: removed now-defunct isAuthenticated mock entry

Checks

  • Adding quotes?
    • Make sure to follow the quotes documentation
    • Make sure to include translations for the quotes in the description (or another comment) so we can verify their content.
  • Adding a language?
    • Make sure to follow the languages documentation
    • Add language to packages/schemas/src/languages.ts
    • Add language to exactly one group in frontend/src/ts/constants/languages.ts
    • Add language json file to frontend/static/languages
  • Adding a theme?
    • Make sure to follow the themes documentation
    • Add theme to packages/schemas/src/themes.ts
    • Add theme to frontend/src/ts/constants/themes.ts
    • (optional) Add theme css file to frontend/static/themes
    • Add some screenshots of the theme, especially with different test settings (colorful, flip colors) to your pull request
  • Adding a layout?
    • Make sure to follow the layouts documentation
    • Add layout to packages/schemas/src/layouts.ts
    • Add layout json file to frontend/static/layouts
  • Adding a font?
    • Make sure to follow the fonts documentation
    • Add font file to frontend/static/webfonts
    • Add font to packages/schemas/src/fonts.ts
    • Add font to frontend/src/ts/constants/fonts.ts
  • Check if any open issues are related to this PR; if so, be sure to tag them below.
  • Make sure the PR title follows the Conventional Commits standard. (https://www.conventionalcommits.org for more info)
  • Make sure to include your GitHub username prefixed with @ inside parentheses at the end of the PR title.

Warning

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
    • Triggering command: /usr/bin/curl curl -q --fail --compressed -L -s REDACTED -o - che/node-gyp/24.-c (dns block)
    • Triggering command: /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)
    • Triggering command: /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
  1. Remove the isAuthenticated function/variable from the codebase by locating its definition and all references to it.
  2. Rename all occurrences of isLoggedIn to isAuthenticated, including its definition, usages, and any imports/exports where applicable.
  3. Ensure that all relevant files are updated accordingly to reflect these changes.
  4. Test and verify that the changes do not introduce any errors or inconsistencies in the application.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Currently we have isloggedin and isauthenticated. Remove isauthenticated, rename is loggedin to isauthenticated, update usage

Assistant: To address this request:

  1. Remove isAuthenticated from the codebase.

    • You need to find and delete the definition and usages of the isAuthenticated function/variable.
  2. Rename isLoggedIn to isAuthenticated.

    • Update the definition and refactor all occurrences of isLoggedIn to isAuthenticated.
  3. Ensure consistent updates across the codebase.

    • Review imports and usages in other files to make sure the naming change is fully reflected.

Would you like me to make these changes directly in a specific repository or provide a list of steps you can follow to implement them? Let me know if additional details or automation support is needed.

User: Monkeytype repo

Assistant: To make the requested changes in the Monkeytype repository:

  1. Remove isAuthenticated:

    • Identify all definitions and usages of isAuthenticated and remove them from the codebase.
  2. Rename isLoggedIn to isAuthenticated:

    • Rename the isLoggedIn function/variable to isAuthenticated and update all references accordingly.

Would you like me to implement these changes directly via a pull request in the Monkeytype repository? If yes, please confirm the repository information (owner/repo), or let me know if you need me to generate a plan instead.

User: Monkeytypegame/monkeytype

Assistant: A pull request has been initiated to make the requested changes in the Monkeytypegame/monkeytype repository. Let me know if you need further updates or adjustments!

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.

Copilot AI changed the title [WIP] Remove isAuthenticated and rename isLoggedIn to isAuthenticated refactor: remove firebase isAuthenticated, rename isLoggedIn to isAuthenticated (@copilot) Mar 28, 2026
Copilot AI requested a review from Miodec March 28, 2026 09:58
@monkeytypegeorge monkeytypegeorge added the frontend User interface or web stuff label Mar 28, 2026
@Miodec Miodec marked this pull request as ready for review March 28, 2026 18:13
Copilot AI review requested due to automatic review settings March 28, 2026 18:13
@github-actions github-actions bot added the waiting for review Pull requests that require a review before continuing label Mar 28, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 isLoggedInisAuthenticated in states/core.ts.
  • Remove isAuthenticated export from firebase.ts.
  • Update call sites (UI, commandline, DB, queries, tests) to import isAuthenticated from states/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.

Comment on lines 23 to +25
} from "./firebase";
import * as Sentry from "./sentry";
import { isAuthenticated } from "./states/core";
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
import { CommandlineConfigMetadataObject } from "./commandline-metadata";
import { isAuthAvailable, isAuthenticated, signOut } from "../firebase";
import { isAuthAvailable, signOut } from "../firebase";
import { isAuthenticated } from "../states/core";
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
import { isAuthenticated } from "../states/core";

Copilot uses AI. Check for mistakes.
@Miodec Miodec merged commit 75ba4aa into master Mar 30, 2026
7 checks passed
@monkeytypegeorge monkeytypegeorge added the assets Languages, themes, layouts, etc. label Mar 30, 2026
@Miodec Miodec deleted the copilot/remove-isauthenticated-rename-isloggedin branch March 30, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

assets Languages, themes, layouts, etc. frontend User interface or web stuff waiting for review Pull requests that require a review before continuing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants