Fix Follow button silent failure for logged-out users#2086
Fix Follow button silent failure for logged-out users#2086slarson wants to merge 1 commit intocodeforboston:mainfrom
Conversation
When a logged-out user clicks the Follow button on the Testimony Detail page, the action silently fails because uid is undefined and Firestore rejects the operation with "Missing or insufficient permissions." This adds an auth guard that redirects to /login?redirect=currentPath, matching the existing auth redirect pattern used elsewhere in the app. Closes codeforboston#2059 Co-authored-with: Claude Code
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Hi! I noticed #2063 also addresses this issue. The reviewer there pointed out that the fix only applied to This PR applies the same auth guard pattern to both components:
I verified the fix end-to-end on the testimony detail page specifically — clicking Follow while logged out now redirects to Happy to coordinate with @saschabuehrle if it makes sense to combine efforts or if there's anything I'm missing! |
Summary
FollowButton.tsxandPolicyActions.tsx/login?redirect=currentPathinstead of silently failingProblem
On the Testimony Detail page, logged-out visitors can click the "Follow H.xx" button. Because
uidis undefined, the FirestoresetFollowcall fails with "Missing or insufficient permissions" — but the user sees no feedback at all.Fix
Added a
!uidcheck inhandleClickfor bothBaseFollowButtonandPolicyActions. If the user isn't authenticated,router.push(/login?redirect=...)sends them to login with a redirect back to the current page. This matches the existingrequireAuthredirect pattern used elsewhere in the app (e.g.auth/service.tsx).Testing
Tested locally against the shared dev Firebase backend (
digital-testimony-dev) using Chrome DevTools Protocol automation:/testimony/JEzCsV1OiC9hwCyrcON5A/1while logged out, clicked "Follow H.54" — confirmed silent failure with unhandled Firestore permission error and no URL change/login?redirect=%2Ftestimony%2FJEzCsV1OiC9hwCyrcON5A%2F1Closes #2059
Co-authored-with: Claude Code