From b99ea597d303e3bea91a7abe647c9ae25fd14770 Mon Sep 17 00:00:00 2001 From: dogukanoksuz Date: Fri, 5 Jul 2024 11:04:10 +0000 Subject: [PATCH] feat: Default auth gate selection --- src/components/ui/user-auth-form.tsx | 34 +++++++++++++++----------- src/pages/settings/advanced/tweaks.tsx | 33 +++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/src/components/ui/user-auth-form.tsx b/src/components/ui/user-auth-form.tsx index 57a0d6a..a5441aa 100644 --- a/src/components/ui/user-auth-form.tsx +++ b/src/components/ui/user-auth-form.tsx @@ -47,16 +47,25 @@ export function UserAuthForm({ className, ...props }: UserAuthFormProps) { const [authTypes, setAuthTypes] = React.useState(["liman"]) React.useEffect(() => { - setIsLoading(true) - apiService - .getInstance() - .get("/auth/types") - .then((res) => { - setAuthTypes(res.data) - }) - .finally(() => { + const fetchAuthData = async () => { + try { + const authTypesResponse = await apiService + .getInstance() + .get("/auth/types") + setAuthTypes(authTypesResponse.data) + + const authGateResponse = await apiService + .getInstance() + .get("/auth/gate") + loginForm.setValue("type", authGateResponse.data) + } catch (error) { + console.error("An error occurred while fetching auth data:", error) + } finally { setIsLoading(false) - }) + } + } + + fetchAuthData() }, []) const formSchema = z.object({ @@ -281,10 +290,7 @@ export function UserAuthForm({ className, ...props }: UserAuthFormProps) { render={({ field }) => (
- @@ -330,7 +336,7 @@ export function UserAuthForm({ className, ...props }: UserAuthFormProps) { - + Şifrenizi mi unuttunuz? diff --git a/src/pages/settings/advanced/tweaks.tsx b/src/pages/settings/advanced/tweaks.tsx index 1465f10..a9148e3 100644 --- a/src/pages/settings/advanced/tweaks.tsx +++ b/src/pages/settings/advanced/tweaks.tsx @@ -10,6 +10,7 @@ import * as z from "zod" import { setFormErrors } from "@/lib/utils" import { Button } from "@/components/ui/button" import { Card } from "@/components/ui/card" +import { Icons } from "@/components/ui/icons" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import PageHeader from "@/components/ui/page-header" @@ -52,6 +53,7 @@ const AdvancedTweaksPage: NextPageWithLayout = () => { NEW_LOG_LEVEL: z.string(), LDAP_IGNORE_CERT: z.boolean(), LOGIN_IMAGE: z.string().optional(), + DEFAULT_AUTH_GATE: z.enum(["ldap", "liman", "keycloak"]), }) const form = useForm>({ @@ -272,6 +274,37 @@ const AdvancedTweaksPage: NextPageWithLayout = () => { )} /> + ( +
+ +
+ + + Burada seçilen giriş kapısı, kullanıcıların oturum açma + sayfasında varsayılan olarak işaretli olacaktır. + +
+ +
+ )} + /> +