Implementing Login

Implementing the Login form is similar to the Register form, however, it involves two steps instead of one. The client must first retrieve the salt from the API, use it to hash the password, and then send a second request to the API to log in. Your implementation may look like this:

import React from 'react';import bcrypt from 'bcryptjs';import { validator } from '../../utils';import Button from '../button/index.jsx';import Input from '../input/index.jsx';function retrieveSalt (email) {  const url = new URL('http://%%API_SERVER_HOST%%:%%API_SERVER_PORT%%/salt/');  url.search = new URLSearchParams({ email });  const request = new Request(url, {    method: 'GET',    mode: 'cors'  });  return fetch(request)    .then(response => { if (response.status ...

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.