link property for ldap

This commit is contained in:
Max Peintner
2025-06-25 08:19:16 +02:00
parent bfb7928b6b
commit 94665022e5
3 changed files with 19 additions and 12 deletions

View File

@@ -46,7 +46,10 @@ export default async function Page(props: {
<Translated i18nKey="description" namespace="ldap" />
</p>
<LDAPUsernamePasswordForm idpId={idpId}></LDAPUsernamePasswordForm>
<LDAPUsernamePasswordForm
idpId={idpId}
link={link === "true"}
></LDAPUsernamePasswordForm>
</div>
</DynamicTheme>
);

View File

@@ -18,9 +18,10 @@ type Inputs = {
type Props = {
idpId: string;
link?: boolean;
};
export function LDAPUsernamePasswordForm({ idpId }: Props) {
export function LDAPUsernamePasswordForm({ idpId, link }: Props) {
const { register, handleSubmit, formState } = useForm<Inputs>({
mode: "onBlur",
});
@@ -39,6 +40,7 @@ export function LDAPUsernamePasswordForm({ idpId }: Props) {
idpId: idpId,
username: values.loginName,
password: values.password,
link: link,
})
.catch(() => {
setError("Could not start LDAP flow");

View File

@@ -34,9 +34,6 @@ export async function redirectToIdp(
const idpId = formData.get("id") as string;
const provider = formData.get("provider") as string;
// const username = formData.get("username") as string;
// const password = formData.get("password") as string;
if (linkOnly) params.set("link", "true");
if (requestId) params.set("requestId", requestId);
if (organization) params.set("organization", organization);
@@ -194,6 +191,7 @@ type createNewSessionForLDAPCommand = {
username: string;
password: string;
idpId: string;
link: boolean;
};
export async function createNewSessionForLDAP(
@@ -229,13 +227,17 @@ export async function createNewSessionForLDAP(
const { userId, idpIntentId, idpIntentToken } = response.nextStep.value;
return {
redirect:
`/idp/ldap/success?` +
new URLSearchParams({
const params = new URLSearchParams({
userId,
id: idpIntentId,
token: idpIntentToken,
}).toString(),
});
if (command.link) {
params.set("link", "true");
}
return {
redirect: `/idp/ldap/success?` + params.toString(),
};
}