import React, {useState} from "react"; import {Trans, useTranslation} from "react-i18next"; import {Alert, Button, Card, Form} from "react-bootstrap"; import {postLdapLogin} from "../../../../../api/user"; import {getAndSetUser} from "../../../../../utils/apiUtils"; import {useSelector} from "react-redux"; import {ApplicationState} from "../../../../../redux"; const ViaLdap: React.FC = () => { const {t} = useTranslation(); const ldapCustomName = useSelector((state: ApplicationState) => state.backendConfig.customAuthNames.ldap); const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(false); const name = ldapCustomName ? `${ldapCustomName} (LDAP)` : "LDAP"; const doAsyncLogin = () => { (async () => { try { await postLdapLogin(username, password); await getAndSetUser(); } catch { setError(true); } })(); } const onFormSubmit = (event: any) => { doAsyncLogin(); event.preventDefault(); } return (
setUsername(event.currentTarget.value)} className="bg-dark text-white" /> setPassword(event.currentTarget.value)} className="bg-dark text-white" />
); }; export { ViaLdap }