Skip to content

Commit

Permalink
feat: Default auth gate selection
Browse files Browse the repository at this point in the history
  • Loading branch information
dogukanoksuz committed Jul 5, 2024
1 parent 945f4ac commit b99ea59
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/components/ui/user-auth-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,25 @@ export function UserAuthForm({ className, ...props }: UserAuthFormProps) {
const [authTypes, setAuthTypes] = React.useState<string[]>(["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({
Expand Down Expand Up @@ -281,10 +290,7 @@ export function UserAuthForm({ className, ...props }: UserAuthFormProps) {
render={({ field }) => (
<div className="flex flex-col gap-2">
<Label htmlFor="type">Giriş Kapısı Seçimi</Label>
<Select
onValueChange={field.onChange}
defaultValue={field.value}
>
<Select onValueChange={field.onChange} value={field.value}>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
Expand Down Expand Up @@ -330,7 +336,7 @@ export function UserAuthForm({ className, ...props }: UserAuthFormProps) {
<Label htmlFor="password">Parola</Label>

<small className="italic text-muted-foreground">
<Link href="/auth/forgot_password">
<Link href="/auth/forgot_password" tabIndex={-1}>
Şifrenizi mi unuttunuz?
</Link>
</small>
Expand Down
33 changes: 33 additions & 0 deletions src/pages/settings/advanced/tweaks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<z.infer<typeof formSchema>>({
Expand Down Expand Up @@ -272,6 +274,37 @@ const AdvancedTweaksPage: NextPageWithLayout = () => {
)}
/>

<FormField
control={form.control}
name="DEFAULT_AUTH_GATE"
render={({ field }) => (
<div className="flex flex-col gap-3">
<Label htmlFor="DEFAULT_AUTH_GATE">
Varsayılan Giriş Kapısı Seçimi
</Label>
<div className="relative">
<Select onValueChange={field.onChange} value={field.value}>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="liman">
<Icons.dugumluLogo className="size-12 h-6" />
</SelectItem>
<SelectItem value="ldap">LDAP</SelectItem>
<SelectItem value="keycloak">Keycloak</SelectItem>
</SelectContent>
</Select>
<small className="italic text-muted-foreground">
Burada seçilen giriş kapısı, kullanıcıların oturum açma
sayfasında varsayılan olarak işaretli olacaktır.
</small>
</div>
<FormMessage />
</div>
)}
/>

<FormField
control={form.control}
name="LOGIN_IMAGE"
Expand Down

0 comments on commit b99ea59

Please sign in to comment.