https://alchemy-react-private-notebook.netlify.app
Use this template to get started.
- Use private routes to enforce auth
- Redirect to an auth page if no user detected
- Retain URL if redirected by auth failure
You and your friend are working on the next big unicorn startup: a note taking app. Your friend has built all the CRUD features for notes, but asked for your help implementing authentication. Two big issues that need to be fixed: user registration and login don't currently do anything when the form is submitted, and anyone can view the notebook (i.e. by visiting one of the following paths: /notes
, /notes/:id
, /notes/:id/edit
). These are the two bugs that you'll need to address.
You'll need to focus on two main areas:
- The
<PrivateRoute>
component right now is a standard route. What it needs is to redirect to the/login
page if the user isn't signed in. - The
Auth
view has an incompleteonSubmit
handler. It needs to either sign up or sign in a user by using the functions in/src/services/users.js
. If signing in, and the sign in is successful, then the user'sid
andemail
should be set in theUserContext
.
The Redirect (Auth) Example from the React Router docs will be helpful when implementing <PrivateRoute>
.
- Users are able to sign up for new accounts
- Users are able to sign in to existing accounts
/notes
,/notes/:id
, and/notes/:id/edit
redirect to the login screen if not signed in
Task | Points |
---|---|
<PrivateRoute> implementation completed |
5 |
Sign up functionality implemented | 2.5 |
Sign In functionality implemented | 2.5 |