From the course: React: Cloud-Powered Apps with Firebase

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: View user profile with admin

Solution: View user profile with admin

From the course: React: Cloud-Powered Apps with Firebase

Start my 1-month free trial

Solution: View user profile with admin

(upbeat electronic music) - [Tutor] Let me show you one way of implementing this feature. Head over now to users.js, our page component, and we can turn the user's name into a navigation link by using link from react router dom, and using the username as the text for this link. We can go ahead and add the to prop, and the path will be /profile/userID. Let's give that a save and head to our browser now. Now, if you try to navigate by clicking on this link, you see that the app doesn't seem to go anywhere. This is because the profile page is using the private route component, which only allows a user to view its own profile. We will need to modify that to allow admin users. Head over now to PrivateRoute.js, and then in our render prop, we can allow the route if that user is an admin. Let's go ahead and grab the isAdmin flag, and we can add a check for the admin user here, or isAdmin. Let's give that a save and try the…

Contents