mirror of
https://github.com/gosticks/web.git
synced 2026-12-03 17:51:39 +00:00
Hash the password before checking with the API
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
This commit is contained in:
Generated
+1453
-18
File diff suppressed because it is too large
Load Diff
+2
-1
@@ -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
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user