Skip to content

fix(frontend): Add flag to check auto-redirect#629

Closed
contre95 wants to merge 1 commit into
tinyauthapp:mainfrom
contre95:fix/redirect_loop
Closed

fix(frontend): Add flag to check auto-redirect#629
contre95 wants to merge 1 commit into
tinyauthapp:mainfrom
contre95:fix/redirect_loop

Conversation

@contre95
Copy link
Copy Markdown
Contributor

@contre95 contre95 commented Feb 5, 2026

The useEffect hook had a dependency on oauthMutation, which changes every time the mutation runs. This caused the effect to re-run indefinitely, creating hundreds of requests to the OIDC provider, in this case/api/oauth/url/pocketid.

This is happening only in tinyauth:nightly

Summary by CodeRabbit

  • Bug Fixes
    • Improved stability of OAuth auto-redirect flow during login to prevent duplicate redirect attempts.
    • Enhanced error handling to ensure proper recovery from OAuth authentication failures.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

The login-page component is enhanced with a guard mechanism to prevent multiple OAuth auto-redirects. A ref tracks redirect state, resets on OAuth errors, and the effect dependency array is optimized to use the mutate function reference. A loose equality check is converted to strict equality.

Changes

Cohort / File(s) Summary
OAuth Auto-Redirect Guard
frontend/src/pages/login-page.tsx
Added hasAutoRedirected ref to prevent duplicate OAuth redirects. On OAuth error, the flag resets to false. Effect dependency improved by referencing oauthMutation.mutate instead of the full mutation object. Strict equality check (===) applied to provider length validation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit guards the redirect door,
No double-taps forevermore!
With refs and flags to mark the way,
The OAuth dance won't loop today! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a flag to prevent auto-redirect loops in the login page.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@contre95 contre95 marked this pull request as ready for review February 5, 2026 18:20
@steveiliop56
Copy link
Copy Markdown
Member

Hey @contre95, thank you for the pull request. I will have to close this one because I am already working on a small refactor for all of the effect calls in #630. In any case thank you for the useRef idea, it does solve a lot of problems!

@contre95 contre95 deleted the fix/redirect_loop branch February 6, 2026 16:07
@contre95
Copy link
Copy Markdown
Contributor Author

contre95 commented Feb 6, 2026

@steveiliop56 No problem ! Just in case, I realized about this issue with the nightly image while trying to access a service behind Tinyauth while not being authenticated.

@steveiliop56
Copy link
Copy Markdown
Member

Yes it was one of the many issues in the alpha/nightly lol.

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