fix(frontend): stop forum login from looping when Flarum auth fails#5311
Conversation
|
/request-review @Yicong-Huang |
|
@aglinxinyuan could you PTAL? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5311 +/- ##
============================================
- Coverage 51.15% 51.12% -0.03%
+ Complexity 2413 2380 -33
============================================
Files 1054 1053 -1
Lines 40923 40514 -409
Branches 4381 4317 -64
============================================
- Hits 20933 20712 -221
+ Misses 18791 18610 -181
+ Partials 1199 1192 -7
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
General comment: can you use a test to guard this behavior? |
Signed-off-by: Matthew B. <mgball@uci.edu>
…pache#5311) ### What changes were proposed in this PR? - Add an `attemptRegister` flag to `DashboardComponent.forumLogin` so a Flarum registration is attempted at most once, breaking the infinite `auth -> register -> auth` cycle that occurred when `auth()` kept failing with a non-404/500 status. - After registering, the recursive call now passes `forumLogin(false)`; if auth still fails on that pass it falls through to `displayForum = false` instead of looping. - Add an error handler to the `register()` subscription so a failed registration hides the forum rather than being silently dropped. ### Any related issues, documentation, or discussions? Closes: apache#5310 ### How was this PR tested? - Ran `yarn format:fix` (clean, no files changed). - Manually traced the control flow: auth fail (non-404/500) now does auth, register, auth, then stop, instead of recursing without bound. ### Was this PR authored or co-authored using generative AI tooling? Co-authored with Claude Opus 4.8 in compliance with ASF --------- Signed-off-by: Matthew B. <mgball@uci.edu>
|
Hi @Ma77Ball, we'd like to include this fix in the v1.2 release. Since this PR was merged before the release/v1.2 label existed, the auto-backport didn't trigger. Could you open a manual backport PR targeting release/v1.2? Please note in the PR description that it is a backport and link the original PR (#5311). Thank you. |
…5311) [release/v1.2 backport] (#5615) ### What changes were proposed in this PR? Backport of #5311 ("fix(frontend): stop forum login from looping when Flarum auth fails") to `release/v1.2`. Applies as a clean `git cherry-pick -x` of the merged squash commit `af664995`, no conflicts and no prerequisite chain. Frontend-only: 2 files changed, 75 insertions, 4 deletions. The introduced diff is identical to the original PR (only blob-index hashes in the patch header differ). For the full change description see #5311. In brief: `DashboardComponent.forumLogin` recursed `auth -> register -> auth` without bound when Flarum `auth()` kept failing with a non-404/500 status. This adds an `attemptRegister` flag so registration is attempted at most once (the post-register call passes `forumLogin(false)`, which then falls through to `displayForum = false`), and adds an error handler on the `register()` subscription so a failed registration hides the forum instead of being silently dropped. ### Any related issues, documentation, discussions? Closes: #5618 (backport tracking task). Backports #5311 (which closes #5310 on `main`). Requested by @xuang7 for the v1.2 release; the PR was merged before the `release/v1.2` label existed, so auto-backport did not trigger. ### How was this PR tested? This is a backport with no changes beyond the single cherry-picked commit, so it relies on the existing tests carried over from #5311 (added cases in `dashboard.component.spec.ts` covering the bounded retry and the failed-registration path). Run them with `yarn test --include='**/dashboard.component.spec.ts'` from `frontend/`. Backport fidelity was verified locally: the diff introduced by the cherry-pick is byte-identical to the original #5311 diff. The `dashboard.component.ts` file is not byte-identical to `main@af66499` only because `release/v1.2` lacks the unrelated footer change (#5153/#5444) that renamed `gitCommitHash`/`Version.raw` to `buildNumber`/`Version.buildNumber`; that line is outside the `forumLogin` fix and is left untouched here. Full compile and unit-test runs are left to CI. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 4.8) Signed-off-by: Matthew B. <mgball@uci.edu>
What changes were proposed in this PR?
attemptRegisterflag toDashboardComponent.forumLoginso a Flarum registration is attempted at most once, breaking the infiniteauth -> register -> authcycle that occurred whenauth()kept failing with a non-404/500 status.forumLogin(false); if auth still fails on that pass it falls through todisplayForum = falseinstead of looping.register()subscription so a failed registration hides the forum rather than being silently dropped.Any related issues, documentation, or discussions?
Closes: #5310
How was this PR tested?
yarn format:fix(clean, no files changed).Was this PR authored or co-authored using generative AI tooling?
Co-authored with Claude Opus 4.8 in compliance with ASF