diff --git a/ui/components/auth/oss/auth-form.tsx b/ui/components/auth/oss/auth-form.tsx index e215abad4f..9a3d1985b9 100644 --- a/ui/components/auth/oss/auth-form.tsx +++ b/ui/components/auth/oss/auth-form.tsx @@ -1,7 +1,7 @@ "use client"; import { zodResolver } from "@hookform/resolvers/zod"; -import { Link } from "@nextui-org/react"; +import { Checkbox, Link, Spacer } from "@nextui-org/react"; import { useRouter } from "next/navigation"; import { useForm } from "react-hook-form"; import { z } from "zod"; @@ -11,7 +11,12 @@ import { NotificationIcon, ProwlerExtended } from "@/components/icons"; import { ThemeSwitch } from "@/components/ThemeSwitch"; import { useToast } from "@/components/ui"; import { CustomButton, CustomInput } from "@/components/ui/custom"; -import { Form } from "@/components/ui/form"; +import { + Form, + FormControl, + FormField, + FormMessage, +} from "@/components/ui/form"; import { ApiError, authFormSchema } from "@/types"; export const AuthForm = ({ @@ -167,6 +172,7 @@ export const AuthForm = ({ /> > )} + {/* {type === "sign-in" && ( @@ -213,16 +223,49 @@ export const AuthForm = ({ isDisabled={invitationToken !== null && true} /> )} + + {process.env.NEXT_PUBLIC_IS_CLOUD_ENV === "true" && ( + ( + <> + + field.onChange(e.target.checked)} + > + I agree with the + + Terms of Service + + of Prowler + + + + > + )} + /> + )} > )} - {form.formState.errors?.email && ( + {type === "sign-in" && form.formState.errors?.email && ( - No user found + Invalid email or password )} + {type === "sign-in" && } + { isRequired?: boolean; isInvalid?: boolean; isDisabled?: boolean; + showFormMessage?: boolean; } export const CustomInput = ({ @@ -41,6 +42,7 @@ export const CustomInput = ({ isRequired = true, isInvalid, isDisabled = false, + showFormMessage = true, }: CustomInputProps) => { const [isPasswordVisible, setIsPasswordVisible] = useState(false); const [isConfirmPasswordVisible, setIsConfirmPasswordVisible] = @@ -112,7 +114,9 @@ export const CustomInput = ({ {...field} /> - + {showFormMessage && ( + + )} > )} /> diff --git a/ui/types/authFormSchema.ts b/ui/types/authFormSchema.ts index ac0fc46dcf..58737a1f8a 100644 --- a/ui/types/authFormSchema.ts +++ b/ui/types/authFormSchema.ts @@ -24,11 +24,21 @@ export const authFormSchema = (type: string) => invitationToken: type === "sign-in" ? z.string().optional() : z.string().optional(), + termsAndConditions: + type === "sign-in" || process.env.NEXT_PUBLIC_IS_CLOUD_ENV !== "true" + ? z.boolean().optional() + : z.boolean().refine((value) => value === true, { + message: "You must accept the terms and conditions.", + }), + // Fields for Sign In and Sign Up email: z.string().email(), - password: z.string().min(12, { - message: "It must contain at least 12 characters.", - }), + password: + type === "sign-in" + ? z.string() + : z.string().min(12, { + message: "It must contain at least 12 characters.", + }), }) .refine( (data) => type === "sign-in" || data.password === data.confirmPassword,
No user found
Invalid email or password