|
@@ -48,6 +48,7 @@ export const LoginForm = (props: LoginFormProps): JSX.Element => {
|
|
|
|
|
|
|
|
// states
|
|
// states
|
|
|
const [isRegistering, setIsRegistering] = useState(false);
|
|
const [isRegistering, setIsRegistering] = useState(false);
|
|
|
|
|
+ const [isLoading, setIsLoading] = useState(false);
|
|
|
// For Login
|
|
// For Login
|
|
|
const [usernameForLogin, setUsernameForLogin] = useState('');
|
|
const [usernameForLogin, setUsernameForLogin] = useState('');
|
|
|
const [passwordForLogin, setPasswordForLogin] = useState('');
|
|
const [passwordForLogin, setPasswordForLogin] = useState('');
|
|
@@ -93,6 +94,7 @@ export const LoginForm = (props: LoginFormProps): JSX.Element => {
|
|
|
const handleLoginWithLocalSubmit = useCallback(async(e) => {
|
|
const handleLoginWithLocalSubmit = useCallback(async(e) => {
|
|
|
e.preventDefault();
|
|
e.preventDefault();
|
|
|
resetLoginErrors();
|
|
resetLoginErrors();
|
|
|
|
|
+ setIsLoading(true);
|
|
|
|
|
|
|
|
const loginForm = {
|
|
const loginForm = {
|
|
|
username: usernameForLogin,
|
|
username: usernameForLogin,
|
|
@@ -112,6 +114,7 @@ export const LoginForm = (props: LoginFormProps): JSX.Element => {
|
|
|
catch (err) {
|
|
catch (err) {
|
|
|
const errs = toArrayIfNot(err);
|
|
const errs = toArrayIfNot(err);
|
|
|
setLoginErrors(errs);
|
|
setLoginErrors(errs);
|
|
|
|
|
+ setIsLoading(false);
|
|
|
}
|
|
}
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
@@ -214,10 +217,10 @@ export const LoginForm = (props: LoginFormProps): JSX.Element => {
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div className="input-group my-4">
|
|
<div className="input-group my-4">
|
|
|
- <button type="submit" id="login" className="btn btn-fill rounded-0 login mx-auto" data-testid="btnSubmitForLogin">
|
|
|
|
|
|
|
+ <button type="submit" id="login" className="btn btn-fill rounded-0 login mx-auto" data-testid="btnSubmitForLogin" disabled={isLoading}>
|
|
|
<div className="eff"></div>
|
|
<div className="eff"></div>
|
|
|
<span className="btn-label">
|
|
<span className="btn-label">
|
|
|
- <i className="icon-login"></i>
|
|
|
|
|
|
|
+ <i className={isLoading ? 'fa fa-spinner fa-pulse mr-1' : 'icon-login'} />
|
|
|
</span>
|
|
</span>
|
|
|
<span className="btn-label-text">{t('Sign in')}</span>
|
|
<span className="btn-label-text">{t('Sign in')}</span>
|
|
|
</button>
|
|
</button>
|
|
@@ -226,7 +229,7 @@ export const LoginForm = (props: LoginFormProps): JSX.Element => {
|
|
|
</>
|
|
</>
|
|
|
);
|
|
);
|
|
|
}, [generateDangerouslySetErrors, generateSafelySetErrors, handleLoginWithLocalSubmit,
|
|
}, [generateDangerouslySetErrors, generateSafelySetErrors, handleLoginWithLocalSubmit,
|
|
|
- isLdapSetupFailed, loginErrors, props, separateErrorsBasedOnErrorCode, t]);
|
|
|
|
|
|
|
+ isLdapSetupFailed, loginErrors, props, separateErrorsBasedOnErrorCode, isLoading, t]);
|
|
|
|
|
|
|
|
const renderExternalAuthInput = useCallback((auth) => {
|
|
const renderExternalAuthInput = useCallback((auth) => {
|
|
|
const authIconNames = {
|
|
const authIconNames = {
|
|
@@ -295,6 +298,7 @@ export const LoginForm = (props: LoginFormProps): JSX.Element => {
|
|
|
e.preventDefault();
|
|
e.preventDefault();
|
|
|
setEmailForRegistrationOrder('');
|
|
setEmailForRegistrationOrder('');
|
|
|
setIsSuccessToRagistration(false);
|
|
setIsSuccessToRagistration(false);
|
|
|
|
|
+ setIsLoading(true);
|
|
|
|
|
|
|
|
const registerForm = {
|
|
const registerForm = {
|
|
|
username: usernameForRegister,
|
|
username: usernameForRegister,
|
|
@@ -323,6 +327,7 @@ export const LoginForm = (props: LoginFormProps): JSX.Element => {
|
|
|
if (err != null || err.length > 0) {
|
|
if (err != null || err.length > 0) {
|
|
|
setRegisterErrors(err);
|
|
setRegisterErrors(err);
|
|
|
}
|
|
}
|
|
|
|
|
+ setIsLoading(false);
|
|
|
}
|
|
}
|
|
|
return;
|
|
return;
|
|
|
}, [usernameForRegister, nameForRegister, emailForRegister, passwordForRegister, resetRegisterErrors, router, isEmailAuthenticationEnabled]);
|
|
}, [usernameForRegister, nameForRegister, emailForRegister, passwordForRegister, resetRegisterErrors, router, isEmailAuthenticationEnabled]);
|
|
@@ -478,11 +483,11 @@ export const LoginForm = (props: LoginFormProps): JSX.Element => {
|
|
|
<button
|
|
<button
|
|
|
className="btn btn-fill rounded-0"
|
|
className="btn btn-fill rounded-0"
|
|
|
id="register"
|
|
id="register"
|
|
|
- disabled={(!isMailerSetup && isEmailAuthenticationEnabled)}
|
|
|
|
|
|
|
+ disabled={(!isMailerSetup && isEmailAuthenticationEnabled) || isLoading}
|
|
|
>
|
|
>
|
|
|
<div className="eff"></div>
|
|
<div className="eff"></div>
|
|
|
<span className="btn-label">
|
|
<span className="btn-label">
|
|
|
- <i className="icon-user-follow"></i>
|
|
|
|
|
|
|
+ <i className={isLoading ? 'fa fa-spinner fa-pulse mr-1' : 'icon-user-follow'} />
|
|
|
</span>
|
|
</span>
|
|
|
<span className="btn-label-text">{submitText}</span>
|
|
<span className="btn-label-text">{submitText}</span>
|
|
|
</button>
|
|
</button>
|
|
@@ -503,7 +508,7 @@ export const LoginForm = (props: LoginFormProps): JSX.Element => {
|
|
|
);
|
|
);
|
|
|
}, [
|
|
}, [
|
|
|
t, isEmailAuthenticationEnabled, registrationMode, isMailerSetup, registerErrors, isSuccessToRagistration,
|
|
t, isEmailAuthenticationEnabled, registrationMode, isMailerSetup, registerErrors, isSuccessToRagistration,
|
|
|
- emailForRegistrationOrder, props.username, props.name, props.email, registrationWhitelist, switchForm, handleRegisterFormSubmit,
|
|
|
|
|
|
|
+ emailForRegistrationOrder, props.username, props.name, props.email, registrationWhitelist, switchForm, handleRegisterFormSubmit, isLoading,
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
if (registrationMode === RegistrationMode.RESTRICTED && isSuccessToRagistration && !isEmailAuthenticationEnabled) {
|
|
if (registrationMode === RegistrationMode.RESTRICTED && isSuccessToRagistration && !isEmailAuthenticationEnabled) {
|