Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Hash password client side (#356)
Browse files Browse the repository at this point in the history
add hash client side password
  • Loading branch information
gfroidcourt authored Dec 11, 2022
1 parent caef74a commit 7c6f600
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/services/API.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Axios from 'axios';
import crypto from 'crypto-js';
import Storage from '../utils/storage';
import AppInfo from '../../app.json';


const DOMAIN_PREFIX = AppInfo.productionMode ? '' : 'preprod-';
const API_BASE_URL = `https://${DOMAIN_PREFIX}api.dropy-app.com`;

Expand All @@ -25,10 +27,11 @@ const init = async () => {
const getHeaders = () => axios.defaults.headers.common;

const register = async (displayName, email, password, newsLetter) => {
const hashedPassword = crypto.SHA256(password).toString();
const response = await axios.post('/register', {
displayName,
email,
password,
hashedPassword,
newsLetter,
});

Expand All @@ -43,9 +46,10 @@ const register = async (displayName, email, password, newsLetter) => {
};

const login = async (email, password) => {
const hashedPassword = crypto.SHA256(password).toString();
const response = await axios.post('/login', {
email,
password,
hashedPassword,
});

const { accessToken, refreshToken, expires, profile: user } = response.data;
Expand Down

0 comments on commit 7c6f600

Please sign in to comment.