import { useState } from "react"; import { useTranslation } from "react-i18next"; import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; import { Button, Input } from "@app/components/v2"; import { loginLDAPRedirect } from "@app/hooks/api/auth/queries"; type Props = { setStep: (step: number) => void; } export const LDAPStep = ({ setStep }: Props) => { const { createNotification } = useNotificationContext(); const [organizationSlug, setOrganizationSlug] = useState(""); const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const { t } = useTranslation(); // const queryParams = new URLSearchParams(window.location.search); const handleSubmission = async (e:React.FormEvent) => { e.preventDefault() try { const { nextUrl } = await loginLDAPRedirect({ organizationSlug, username, password }); if (!nextUrl) { createNotification({ text: "Login unsuccessful. Double-check your credentials and try again.", type: "error" }); return; } createNotification({ text: "Successfully logged in", type: "success" }); // redirects either to /login/sso or /signup/sso window.open(nextUrl); window.close(); } catch (err) { createNotification({ text: "Login unsuccessful. Double-check your credentials and try again.", type: "error" }); } // TODO: add callback port support // const callbackPort = queryParams.get("callback_port"); // window.open(`/api/v1/ldap/redirect/saml2/${ssoIdentifier}${callbackPort ? `?callback_port=${callbackPort}` : ""}`); // window.close(); } return (

What's your LDAP Login?

setOrganizationSlug(e.target.value)} type="text" placeholder="Enter your organization slug..." isRequired autoComplete="email" id="email" className="h-12" />
setUsername(e.target.value)} type="text" placeholder="Enter your LDAP username..." isRequired autoComplete="email" id="email" className="h-12" />
setPassword(e.target.value)} type="password" placeholder="Enter your LDAP password..." isRequired autoComplete="current-password" id="current-password" className="select:-webkit-autofill:focus h-10" />
); };