@dloizides/auth-web 1.18.2 → 1.18.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -617,7 +617,11 @@ function useLoginSubmit({
617
617
  invalidCredentialsLabel
618
618
  }) {
619
619
  const [errorText, setErrorText] = useState(null);
620
+ const inFlight = useRef(false);
620
621
  const runLogin = useCallback(async () => {
622
+ if (inFlight.current) {
623
+ return;
624
+ }
621
625
  setErrorText(null);
622
626
  const trimmedUsername = username.trim();
623
627
  const hasMissingField = trimmedUsername.length === 0 || password.length === 0;
@@ -625,11 +629,14 @@ function useLoginSubmit({
625
629
  setErrorText(missingFieldsLabel);
626
630
  return;
627
631
  }
632
+ inFlight.current = true;
628
633
  try {
629
634
  const user = await login({ username: trimmedUsername, password });
630
635
  onSuccess(user);
631
636
  } catch {
632
637
  setErrorText(invalidCredentialsLabel);
638
+ } finally {
639
+ inFlight.current = false;
633
640
  }
634
641
  }, [username, password, login, onSuccess, missingFieldsLabel, invalidCredentialsLabel]);
635
642
  const handleSubmit = useCallback(() => {