September 2018
Intermediate to advanced
764 pages
20h 6m
English
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 ...Read now
Unlock full access