quran / quran.com-frontend-next

Frontend build on next.js
https://quran.com
1.37k stars 399 forks source link

Add hoc to redirect to login page #2103

Closed osamasayed closed 7 months ago

osamasayed commented 7 months ago

Summary

Currently, we are using useRequireAuth hook as a way to redirect to login page when a non-logged in user is trying to access authenticated components. But issue is at least 1 request is sent to backend that fails while Frontend already knows the user is not logged in. So This PR is introducing a Higher-Order-Component withAuth that will not render authenticated components except when the user is logged in, otherwise redirects the user to login page.

vercel[bot] commented 7 months ago

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

Name Status Preview Comments Updated (UTC)
quran-com ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 4, 2024 4:15pm