We've redeployed TheIndex API. Now you can't create authors or books without being logged in.
-
Fork the repository
-
Clone it.
-
cd
into the project directory. -
Install the required packages for the task.
$ yarn install
-
Run the project
$ yarn start
Take some time to explore the starting code. You should find an actions file and a reducer for authentication. You should also find new forms for login and signup.
Right now the book and author posting actions will always fail. That's because we have to be logged in with a valid token to use them. Implement login and signup to get them to work again.
- Complete the reducer in
reducers/user.js
. - Complete the
login
andsignup
actions inactions/authentication.js
.
Don't forget to set theAuthentication
header foraxios
.
The endpoints in the backend are: - Connect these actions to the login and signup forms.
- Create an account and log in. The posting forms should now work again.
- If the user is logged in, the login and signup buttons in the
Sidebar
should be replaced with a logout button that includes theusername
. - This button should log the user out (surprise!)
- The "add author" card should only be visible for logged in users.
- The "add new book" button should only be visible for logged in users.
- Only users who are not logged in should be able to go to
/login
and/signup
. Users who are already logged in should be redirected to the home page. - Login should be persistent. If I log in and then refresh the page, I should still be logged in!
- Push your code.