Almost every website in the world has user authentication. In this project you have to implement user authentication using Node for building a backend REST API and React.js and sessionStorage API for the frontend web application.
Implement an authentication system with the following parts:
At least the following pages and react components must be implemented into the project:
Path | Component | Functionality |
---|---|---|
/signup | <Signup> | Renders the signup form |
/login | <Login> | Renders the login form |
/private | <Private> | Validates that only authenticated users and render this component |
Do not clone this repository.
a) If using Gitpod (recommended) you can clone the boilerplate by clicking here.
b) If working locally type the following command from your command line: git clone https://github.com/4GeeksAcademy/expressjs-rest-hello
.
๐ก Remember to create a new repository, update the remote (git remote set-url origin <your new url>
), and upload the code to your new repository using add
, commit
and push
.
Usually an authentication system is implemented in 4 parts:
At the beginning of every application that are not users or tokens, so the first step that makes sense to build is user signup.
/signup
path at frontend./signup
and match with its corresponding React.js page component that will take care of rendering the signup HTML.handleSubmit
function fetches the email and password to the backend Node API, probably doing a POST /token
request with the email and password on the body payload.This part of the process occurs only when new tokens have to be generated.
/login
path, in the frontend./login
path and match it with its corresponding React.js page component, this page will take care of rendering the login form.token
object.sessionStorage
./private
.This process occurs when the user desires to logout.
onClick
event handler is called.token
from the sessionStorage
.Any user can just type /private
to attempt visiting a private page, that is why we need to implement a validation that prevents the anonymous users to see the content of this page, and we must redirect the user to /login
or any other public page. This is usually how the process goes:
/private
/private
and match with its corresponding React.js page component that will take care of rendering the HTML.sessionStorage
๐ does not have the token
, the current user is not considered to be logged in and the component must redirect to the login view./private
view component is loaded.