Skip to content

fix(auth): unify modal logic for all protected pages and improve logi… #1852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chaoyi09
Copy link

Summary

This PR extends and improves the protected page authentication modal logic originally implemented for the newsfeed page (see #1841). Now, all protected pages (newsfeed, edit profile, submit testimony) use a unified modal-based authentication flow. The user experience is more consistent and several known issues are fixed.

Checklist

  • Fixed modal flash when refreshing the newsfeed page after login.
  • All protected pages use unified modal logic.
  • Modal text is now translatable (previously hardcoded).
  • Pages are responsive on mobile.
  • No modal flash or auto-trigger after logout (Not fully resolved, see Known Issues)

Screenshots

image image

Known issues

  • Logout Modal Issue:
    After logging out from a protected page, the login modal may still auto-trigger immediately on the homepage. This is due to some logout flows not fully respecting the justLoggedOut flag or not using the useLogoutWithDelay hook everywhere.
    • Workaround: Ensure all logout actions use useLogoutWithDelay instead of signOutAndRedirectToHome or direct auth.signOut().
    • Follow-up: Further refactoring is needed to guarantee the modal never auto-triggers after logout in all scenarios.

Steps to test

To verify modal flash is fixed:

  1. Log in and go to /newsfeed.
  2. Refresh the page.
  3. Expected: No login modal flash; content loads directly.

To verify unified modal logic:

  1. Log out.
  2. Visit /newsfeed, /edit-profile, or /submit-testimony.
  3. Expected: Login/signup modal appears; page content is hidden until login.

To verify translation is working:

  1. Log out.
  2. Visit /newsfeed.
  3. When the login modal appears, check that the title and content are using translation keys (e.g. "Login Required", "You need to be logged in to access this page.") and not hardcoded.
  4. (If your site supports multiple languages) Switch to another language and confirm the modal text updates accordingly.

To reproduce the known logout issue:

  1. Log in and visit a protected page.
  2. Log out (using any logout button).
  3. Expected: Should redirect to homepage and not show modal immediately.
  4. Actual: Sometimes the login modal still auto-triggers after logout.

Copy link

vercel bot commented Jul 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
maple-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2025 6:35am

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.

1 participant