From e07c833caba1ad59a62323ed4db9d0bbdf3e61b3 Mon Sep 17 00:00:00 2001 From: Alejandro Bailo <59607668+alejandrobailo@users.noreply.github.com> Date: Mon, 14 Jul 2025 17:04:23 +0200 Subject: [PATCH] feat: SAML toast error (#8267) Co-authored-by: Pepe Fagoaga --- ui/components/auth/oss/auth-form.tsx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/ui/components/auth/oss/auth-form.tsx b/ui/components/auth/oss/auth-form.tsx index 211d238341..a965204dbc 100644 --- a/ui/components/auth/oss/auth-form.tsx +++ b/ui/components/auth/oss/auth-form.tsx @@ -3,7 +3,8 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { Icon } from "@iconify/react"; import { Button, Checkbox, Divider, Link, Tooltip } from "@nextui-org/react"; -import { useRouter } from "next/navigation"; +import { useRouter, useSearchParams } from "next/navigation"; +import { useEffect } from "react"; import { useForm } from "react-hook-form"; import { z } from "zod"; @@ -41,6 +42,24 @@ export const AuthForm = ({ }) => { const formSchema = authFormSchema(type); const router = useRouter(); + const searchParams = useSearchParams(); + const { toast } = useToast(); + + useEffect(() => { + const samlError = searchParams.get("sso_saml_failed"); + + if (samlError) { + // Add a delay to the toast to ensure it is rendered + setTimeout(() => { + toast({ + variant: "destructive", + title: "SAML Authentication Error", + description: + "An error occurred while attempting to login via your Identity Provider (IdP). Please check your IdP configuration.", + }); + }, 100); + } + }, [searchParams, toast]); const form = useForm>({ resolver: zodResolver(formSchema), @@ -58,7 +77,6 @@ export const AuthForm = ({ }); const isLoading = form.formState.isSubmitting; - const { toast } = useToast(); const isSamlMode = form.watch("isSamlMode"); const onSubmit = async (data: z.infer) => {