GitCodeCareer / hiring-system

CodeCareer is seeking core contributors to take the lead on this project.
GNU General Public License v3.0
20 stars 17 forks source link

Private Routes #46

Closed nikhil-chacko closed 3 years ago

nikhil-chacko commented 3 years ago

ISSUE #18

Aim was to create a hoc file to check for token and admin but the hoc routing does not work in react router v4+. I have added the below link as reference

https://medium.com/today-i-learned-chai/protect-route-in-react-router-using-hoc-got-dispatching-infinity-loop-59999a2d7c12

So I created Privates route with the new approach mentioned in the article. Now the user can only view protected routes when they have a token and user can only view admin panel if their isAdmin prop is set to true

Please check the PR and comment for changes