Skip to content

fix: the login method cannot be displayed under the aff link. - #2676

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:fix/aff-login-method
Jan 21, 2026
Merged

fix: the login method cannot be displayed under the aff link.#2676
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:fix/aff-login-method

Conversation

@seefs001

@seefs001 seefs001 commented Jan 15, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Refactor
    • Improved state management in authentication forms for better reliability and consistency.
    • Enhanced handling of status properties with more robust fallback logic.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Both LoginForm and RegisterForm components are refactored to consume status from a centralized StatusContext instead of local state, with localStorage fallback. Properties are accessed via optional chaining to handle undefined status values.

Changes

Cohort / File(s) Summary
Auth Forms - React Context Integration
web/src/components/auth/LoginForm.jsx, web/src/components/auth/RegisterForm.jsx
Integrated StatusContext consumption; replaced useState-based status initialization with useMemo that prioritizes statusState.status over localStorage fallback. Updated all status property access to use optional chaining (e.g., status?.turnstile_check, status?.email_verification) for safe undefined handling. Adjusted useEffect dependencies and logic to accommodate new status derivation pattern.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through context green,
Where status flows, centralized and clean.
No localStorage lurks, no useState to fear,
Just optional chains and StatusContext near!
This refactor makes the code quite dear! 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title claims to fix a display issue with login methods under an aff link, but the actual changes only modify LoginForm.jsx and RegisterForm.jsx to add StatusContext support and improve status handling with optional chaining—no changes related to aff links or login method visibility. Update the PR title to accurately reflect the actual changes, such as 'refactor: use StatusContext and improve status handling in auth forms' or similar.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ef99f4 and f966151.

📒 Files selected for processing (2)
  • web/src/components/auth/LoginForm.jsx
  • web/src/components/auth/RegisterForm.jsx
🧰 Additional context used
🧬 Code graph analysis (2)
web/src/components/auth/RegisterForm.jsx (3)
web/src/components/auth/LoginForm.jsx (2)
  • statusState (77-77)
  • status (113-122)
web/src/App.jsx (1)
  • statusState (60-60)
web/src/components/settings/OtherSetting.jsx (1)
  • statusState (54-54)
web/src/components/auth/LoginForm.jsx (5)
web/src/components/auth/RegisterForm.jsx (2)
  • statusState (76-76)
  • status (111-120)
web/src/components/settings/personal/cards/NotificationSettings.jsx (1)
  • statusState (59-59)
web/src/App.jsx (1)
  • statusState (60-60)
web/src/components/topup/index.jsx (1)
  • statusState (45-45)
web/src/components/settings/PersonalSetting.jsx (1)
  • status (62-62)
🔇 Additional comments (7)
web/src/components/auth/LoginForm.jsx (4)

20-23: LGTM! Correct imports added for StatusContext integration.

The addition of useMemo and StatusContext imports aligns with the pattern used elsewhere in the codebase (e.g., App.jsx, NotificationSettings.jsx).


77-77: LGTM!

StatusContext consumption follows the established pattern used throughout the codebase.


113-122: Good fix for the affiliate link issue.

The useMemo correctly prioritizes statusState.status from context while falling back to localStorage when context isn't yet populated. The error handling for JSON parsing is appropriate.

One minor observation: the || {} on line 118 is redundant since JSON.parse(savedStatus) would return an object if savedStatus contains valid JSON, and if it throws, the catch block handles it. However, this provides an extra safety net for edge cases like JSON.parse("null") returning null.


124-133: LGTM! Optional chaining properly guards against undefined status.

The optional chaining on status?.turnstile_check, status?.user_agreement_enabled, and status?.privacy_policy_enabled ensures safe access during initial render when status might still be empty.

web/src/components/auth/RegisterForm.jsx (3)

20-20: LGTM!

Import changes are consistent with LoginForm.jsx.


111-122: Consistent implementation with LoginForm.jsx.

The useMemo fallback pattern and the separate useState initialization for showEmailVerification (with subsequent update in useEffect) correctly handle the case where status isn't immediately available from context.


124-134: LGTM! Status-dependent state correctly synchronized in useEffect.

The double negation (!!) ensures showEmailVerification is always a boolean, and optional chaining guards against undefined status properties.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Calcium-Ion
Calcium-Ion merged commit 4a6e423 into QuantumNous:main Jan 21, 2026
1 check passed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
fix: the login method cannot be displayed under the aff link.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants