|
@@ -36,6 +36,7 @@ type LoginFormProps = {
|
|
|
}
|
|
}
|
|
|
export const LoginForm = (props: LoginFormProps): JSX.Element => {
|
|
export const LoginForm = (props: LoginFormProps): JSX.Element => {
|
|
|
const { t } = useTranslation();
|
|
const { t } = useTranslation();
|
|
|
|
|
+
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
const {
|
|
const {
|
|
@@ -71,7 +72,13 @@ export const LoginForm = (props: LoginFormProps): JSX.Element => {
|
|
|
}
|
|
}
|
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
|
|
- // functions
|
|
|
|
|
|
|
+ const tWithOpt = useCallback((key: string, opt?: any): string => {
|
|
|
|
|
+ if (typeof opt === 'object') {
|
|
|
|
|
+ return t(key, opt as object);
|
|
|
|
|
+ }
|
|
|
|
|
+ return t(key);
|
|
|
|
|
+ }, [t]);
|
|
|
|
|
+
|
|
|
const handleLoginWithExternalAuth = useCallback((e) => {
|
|
const handleLoginWithExternalAuth = useCallback((e) => {
|
|
|
const auth = e.currentTarget.id;
|
|
const auth = e.currentTarget.id;
|
|
|
|
|
|
|
@@ -133,26 +140,32 @@ export const LoginForm = (props: LoginFormProps): JSX.Element => {
|
|
|
return (
|
|
return (
|
|
|
<div className="alert alert-danger">
|
|
<div className="alert alert-danger">
|
|
|
{errors.map((err, index) => {
|
|
{errors.map((err, index) => {
|
|
|
- return <small key={index} dangerouslySetInnerHTML={{ __html: t(err.message, err.args) }}></small>;
|
|
|
|
|
|
|
+ return <small key={index} dangerouslySetInnerHTML={{ __html: tWithOpt(err.message, err.args) }}></small>;
|
|
|
})}
|
|
})}
|
|
|
</div>
|
|
</div>
|
|
|
);
|
|
);
|
|
|
- }, [t]);
|
|
|
|
|
|
|
+ }, [tWithOpt]);
|
|
|
|
|
|
|
|
// wrap error elements which do not use dangerouslySetInnerHtml
|
|
// wrap error elements which do not use dangerouslySetInnerHtml
|
|
|
const generateSafelySetErrors = useCallback((errors: (IErrorV3 | IExternalAccountLoginError)[]): JSX.Element => {
|
|
const generateSafelySetErrors = useCallback((errors: (IErrorV3 | IExternalAccountLoginError)[]): JSX.Element => {
|
|
|
|
|
+ errors.push(
|
|
|
|
|
+ new Error('foo'),
|
|
|
|
|
+ new Error('foo'),
|
|
|
|
|
+ new Error('foo'),
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
if (errors == null || errors.length === 0) return <></>;
|
|
if (errors == null || errors.length === 0) return <></>;
|
|
|
return (
|
|
return (
|
|
|
<ul className="alert alert-danger">
|
|
<ul className="alert alert-danger">
|
|
|
{errors.map((err, index) => {
|
|
{errors.map((err, index) => {
|
|
|
return (
|
|
return (
|
|
|
- <li key={index}>
|
|
|
|
|
- {t(err.message, err.args)}<br/>
|
|
|
|
|
|
|
+ <li key={index} className={index > 0 ? 'mt-1' : ''}>
|
|
|
|
|
+ {tWithOpt(err.message, err.args)}
|
|
|
</li>);
|
|
</li>);
|
|
|
})}
|
|
})}
|
|
|
</ul>
|
|
</ul>
|
|
|
);
|
|
);
|
|
|
- }, [t]);
|
|
|
|
|
|
|
+ }, [tWithOpt]);
|
|
|
|
|
|
|
|
const renderLocalOrLdapLoginForm = useCallback(() => {
|
|
const renderLocalOrLdapLoginForm = useCallback(() => {
|
|
|
const { isLdapStrategySetup } = props;
|
|
const { isLdapStrategySetup } = props;
|