From b47b18c373df74a698db634fd8d3b1304579be86 Mon Sep 17 00:00:00 2001 From: Alexander Polynomdivision Date: Sun, 30 Sep 2018 18:32:36 +0200 Subject: [PATCH] feat: Prevent invalid logins Do not sent a request to authenticate against the server when either the username or the password are empty --- frontend/src/pages/login.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/login.tsx b/frontend/src/pages/login.tsx index e68c276..5781aad 100644 --- a/frontend/src/pages/login.tsx +++ b/frontend/src/pages/login.tsx @@ -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);