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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.