Skip to content

fix: enforce authentication before loading leaderboard - #12

Merged
rogdex24 merged 1 commit into
mainfrom
codex/add-authentication-check-to-leaderboardscreen
Oct 2, 2025
Merged

fix: enforce authentication before loading leaderboard#12
rogdex24 merged 1 commit into
mainfrom
codex/add-authentication-check-to-leaderboardscreen

Conversation

@rogdex24

@rogdex24 rogdex24 commented Oct 2, 2025

Copy link
Copy Markdown
Owner

Summary

  • add an authentication pre-check on the leaderboard screen so unauthenticated users are routed through name entry
  • allow the player name flow to return to the leaderboard after successful authentication

Testing

  • pnpm --filter frontend lint

https://chatgpt.com/codex/tasks/task_b_68de73c72c1083228b7b6892ac4a1723

Copilot AI review requested due to automatic review settings October 2, 2025 12:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enforces authentication before allowing users to access the leaderboard screen by redirecting unauthenticated users to the player name entry flow.

  • Adds authentication pre-check to the leaderboard screen that routes unauthenticated users through name entry
  • Updates player name flow to support returning to the leaderboard after successful authentication
  • Implements proper component lifecycle management with mount checking to prevent state updates on unmounted components

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
frontend/src/types/components.ts Adds 'Leaderboard' as a valid navigation target for PlayerNameScreen
frontend/src/components/onboarding/PlayerNameScreen/PlayerNameScreen.tsx Adds navigation logic to route to Leaderboard screen after name entry
frontend/src/components/leaderboard/LeaderboardScreen/LeaderboardScreen.tsx Implements authentication check and proper lifecycle management for leaderboard loading

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +88 to +90
const { playerName } = usePlayer();
const trimmedName = playerName.trim();
const hasPlayerName = trimmedName.length > 0;

Copilot AI Oct 2, 2025

Copy link

Choose a reason for hiding this comment

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

The playerName.trim() operation is executed on every render. Consider memoizing this computation using useMemo to avoid unnecessary string operations when playerName hasn't changed.

Copilot uses AI. Check for mistakes.
}
}, [ensureAuthenticated, hasPlayerName, loadLeaderboard, navigation]);

useEffect(() => {

Copilot AI Oct 2, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] Using 'void' to ignore the promise return value in useEffect is acceptable, but consider adding error handling or at least a comment explaining why the promise rejection is intentionally not handled here.

Suggested change
useEffect(() => {
useEffect(() => {
// All errors are handled inside verifyAndLoad; promise rejection is intentionally ignored here.

Copilot uses AI. Check for mistakes.
@rogdex24
rogdex24 merged commit 9fc4f4b into main Oct 2, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants