|
|
|
@ -32,15 +32,23 @@ class Login extends Component { |
|
|
|
// 123Abc!&
|
|
|
|
// 123Abc!&
|
|
|
|
|
|
|
|
|
|
|
|
login() { |
|
|
|
login() { |
|
|
|
fetch("/login", { method: "POST", body: JSON.stringify(this.state) }) |
|
|
|
if (this.state.username !== "" && this.state.password !== "") { |
|
|
|
.then(function(response) { |
|
|
|
var formData = new URLSearchParams(); |
|
|
|
if (response.status === 200) return response.json(); |
|
|
|
formData.append("username", this.state.username); |
|
|
|
else return response.statusText; |
|
|
|
formData.append("password", this.state.password); |
|
|
|
}) |
|
|
|
fetch("https://local.tobi.one/eva/login", { |
|
|
|
.then(function(myJson) { |
|
|
|
method: "POST", |
|
|
|
console.log(myJson); |
|
|
|
body: formData, |
|
|
|
//document.cookie = myJson;
|
|
|
|
headers: { |
|
|
|
|
|
|
|
"content-type": "application/x-www-form-urlencoded;charset=UTF-8" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}).then(response => { |
|
|
|
|
|
|
|
if (response.status === 200) { |
|
|
|
|
|
|
|
console.log("Logged in!"); |
|
|
|
|
|
|
|
this.props.history.push("/"); |
|
|
|
|
|
|
|
} else console.log(response.statusText); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
render() { |
|
|
|
@ -71,7 +79,7 @@ class Login extends Component { |
|
|
|
<Grid item xs={12}> |
|
|
|
<Grid item xs={12}> |
|
|
|
<TextField |
|
|
|
<TextField |
|
|
|
fullWidth={true} |
|
|
|
fullWidth={true} |
|
|
|
id="outlined-name" |
|
|
|
id="outlined-password" |
|
|
|
label="Password" |
|
|
|
label="Password" |
|
|
|
className={classes.textField} |
|
|
|
className={classes.textField} |
|
|
|
value={this.state.password} |
|
|
|
value={this.state.password} |
|
|
|
|