Skip to content

Commit

Permalink
Improve log in page button handling
Browse files Browse the repository at this point in the history
Disable the log in button while "logging in" is in progress, or if the
username and password are empty

Fixes: #581

Signed-off-by: Mark Reynolds <mreynolds@redhat.com>
  • Loading branch information
mreynolds389 committed Oct 17, 2024
1 parent bdacb96 commit 3d7c767
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/login/LoginMainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const LoginMainPage = () => {
const [isValidUsername, setIsValidUsername] = React.useState(true);
const [password, setPassword] = React.useState("");
const [isValidPassword, setIsValidPassword] = React.useState(true);
const [authenticating, setAuthenticating] = React.useState(false);

// Authentication method (assumes user + password by default)
// - This will help to get the user credentials if the user is logged in via Kerberos
Expand Down Expand Up @@ -216,6 +217,7 @@ const LoginMainPage = () => {
setIsValidPassword(!!password);
setShowHelperText(!username || !password);

setAuthenticating(true);
if (!username && isKerberosEnabled) {
onKrbLogin().then((response) => {
if ("error" in response) {
Expand Down Expand Up @@ -261,13 +263,15 @@ const LoginMainPage = () => {
} else {
onSuccessLogin();
}
setAuthenticating(false);
});
}
};

// Login using certificate
const onLoginWithCertClick = (_event) => {
_event.preventDefault();
setAuthenticating(true);
onCertLogin(username).then((response) => {
if ("error" in response) {
const receivedError = response.error as MetaResponse;
Expand All @@ -284,6 +288,7 @@ const LoginMainPage = () => {
} else {
onSuccessLogin();
}
setAuthenticating(false);
});
};

Expand Down Expand Up @@ -334,6 +339,7 @@ const LoginMainPage = () => {
isValidPassword={isValidPassword}
onLoginButtonClick={onLoginButtonClick}
loginButtonLabel="Log in"
isLoginButtonDisabled={authenticating}
/>
);

Expand Down

0 comments on commit 3d7c767

Please sign in to comment.