uw-datasci / uwdsc-website-v2

Website for UWaterloo's Data Science Club
https://www.uwdatascience.ca
4 stars 1 forks source link

Karthik/qrcode detection #59

Closed karthikkrishna1 closed 1 month ago

karthikkrishna1 commented 1 month ago

Added the isAdmin component which could be wrapped around any of the components and if the user is not logged in or not an admin, it will redirect them to the home page.

vercel[bot] commented 1 month ago

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

Name Status Preview Comments Updated (UTC)
uwdsc-website-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 9, 2024 5:25am
karthikkrishna1 commented 1 month ago

Hi, I made the changes you requested. I added an authorization page and redirect to it in the authPage component. It now takes a list of strings and checks if the users role is present in it.

dscwebdev commented 1 month ago

Hey, I've made some minor changes, mainly dealing with naming. Your build was failing because the authPage component does not satisfy the React rule-of-hooks which has some strict naming conventions when it comes to React FCs.

Other than that I've decided to stick with the withAuth name to signify a HOC according to the article below : https://www.freecodecamp.org/news/higher-order-components-in-react/

For future reference, run npm run build before to check of ES lint errors among other build time errors. You're free to merge this branch in whenever Xin Huey approves it as well.