feat: Prevent invalid logins

Do not sent a request to authenticate against the server
when either the username or the password are empty
This commit is contained in:
Alexander Polynomdivision 2018-09-30 18:32:36 +02:00
parent 048f375724
commit b47b18c373

View File

@ -32,10 +32,20 @@ const LoginPageWithRouter = withRouter(
private passwordRef: any = undefined;
performLogin = () => {
this.props.setLoading(true);
// Check if the inputs are even valid
const username = this.usernameRef.value || "";
const password = this.passwordRef.value || "";
if (!username) {
this.props.setSnackbar(true, "Ungültiger Nutzername");
return;
}
if (!password) {
this.props.setSnackbar(true, "Ungültiges Passwort");
return;
}
this.props.setLoading(true);
this.props.login(username, password).then((res: IUser) => {
// Stop the loading animation
this.props.setLoading(false);