Hash the password before checking with the API

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
This commit is contained in:
Mcat12
2018-04-30 00:25:06 -04:00
parent 5c66a7d1de
commit e7ecb9e4fc
3 changed files with 1462 additions and 22 deletions
+1453 -18
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -24,7 +24,8 @@
"react-router-dom": "4.1.1",
"react-table": "^6.5.1",
"react-transition-group": "^1.2.0",
"reactstrap": "4.6.2"
"reactstrap": "4.6.2",
"sha.js": "^2.4.11"
},
"scripts": {
"start": "react-scripts start",
+7 -3
View File
@@ -9,6 +9,7 @@
* Please see LICENSE file for your rights under this license. */
import React, { Component } from 'react';
import sha from 'sha.js';
import { api } from "../utils";
import logo from '../img/logo.svg';
@@ -27,10 +28,11 @@ export default class Login extends Component {
};
onAuth = () => {
const password = this.state.password;
this.setState({ password: '', error: false });
// Hash the password twice before sending to the API
let hashedPassword = sha("sha256").update(this.state.password).digest("hex");
hashedPassword = sha("sha256").update(hashedPassword).digest("hex");
api.authenticate(password)
api.authenticate(hashedPassword)
.then(() => {
// Assume it's ok since there was no error
// TODO: verify response
@@ -38,6 +40,8 @@ export default class Login extends Component {
console.log("Logged In");
})
.catch(() => this.setState({ error: true }));
this.setState({ password: '', error: false });
};
render() {