Protected Routes and Authorisation — Concept Check
Questions on Protected Routes and Authorisation. A route guard is a UX affordance, not a security boundary. It hides what the user cannot use and sends them somewhere sensible — the server still decides what they may actually do.
Questions in this quiz
7 questions on Protected Routes and Authorisation — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.In a React application, if a user tries to access a protected route without being authenticated, what happens?
- AThey gain access to the route.
- BThey see a blank page.
- CThey are redirected to the login page.
- DThey receive a 403 Forbidden error.
2.A user is signed in but tries to access an admin-only route. What is the expected behavior?
- AThey see a 403 Forbidden page.
- BThey gain access to the admin route.
- CThey see a login prompt.
- DThey are redirected to the homepage.
3.What happens if a session expires while a user is filling out a form?
- AThey are prompted to reauthenticate.
- BThe form automatically saves their input.
- CThey lose all their input data.
- DThey are redirected to the login page.
4.Why is it important to replace the redirect when sending users back after login?
- ATo ensure faster page loading.
- BTo improve session security.
- CTo simplify the routing logic.
- DTo avoid redirect loops that trap the user.
5.What is the role of the useBlocker hook in a React application?
- ATo handle session timeouts.
- BTo block unauthorized API requests.
- CTo prevent navigation away from unsaved forms.
- DTo manage user authentication state.
6.If a user with a 'basic' role attempts to access a 'pro' feature, what should ideally happen?
- AThey gain access to the feature.
- BThey see an upgrade prompt.
- CThey are redirected to the homepage.
- DThey receive a 403 Forbidden error.
7.What is a key reason for implementing server-side checks for protected routes?
- AThey eliminate the need for authentication.
- BClient-side checks can be bypassed.
- CThey improve application performance.
- DThey simplify client-side code.