mirror of
https://codeberg.org/MarkusThielker/next-ory.git
synced 2025-04-19 09:01:18 +00:00
NORY-46: remove owner autofill
This commit is contained in:
parent
749974b7ec
commit
edbb93c03b
1 changed files with 12 additions and 20 deletions
|
@ -7,12 +7,11 @@ import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
|
import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { kratos } from '@/ory';
|
import { useState } from 'react';
|
||||||
import { useEffect, useState } from 'react';
|
import { OAuth2Client } from '@ory/client';
|
||||||
import { Identity, OAuth2Client } from '@ory/client';
|
|
||||||
import { AxiosResponse } from 'axios';
|
import { AxiosResponse } from 'axios';
|
||||||
import { AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle } from '@/components/ui/alert-dialog';
|
import { AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle } from '@/components/ui/alert-dialog';
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import { Checkbox } from '@/components/ui/checkbox';
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
|
|
||||||
|
@ -23,13 +22,6 @@ interface CreateClientFormProps {
|
||||||
export function CreateClientForm({ action }: CreateClientFormProps) {
|
export function CreateClientForm({ action }: CreateClientFormProps) {
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [identity, setIdentity] = useState<Identity | undefined>();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
kratos.toSession()
|
|
||||||
.then(response => response.data)
|
|
||||||
.then(session => setIdentity(session.identity));
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const form = useForm<z.infer<typeof clientFormSchema>>({
|
const form = useForm<z.infer<typeof clientFormSchema>>({
|
||||||
resolver: zodResolver(clientFormSchema),
|
resolver: zodResolver(clientFormSchema),
|
||||||
|
@ -61,10 +53,6 @@ export function CreateClientForm({ action }: CreateClientFormProps) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
form.setValue('owner', identity?.id ?? '');
|
|
||||||
}, [identity]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{
|
{
|
||||||
|
@ -180,7 +168,8 @@ export function CreateClientForm({ action }: CreateClientFormProps) {
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}/>
|
)}
|
||||||
|
/>
|
||||||
{
|
{
|
||||||
!form.getValues('skip') && (
|
!form.getValues('skip') && (
|
||||||
<>
|
<>
|
||||||
|
@ -199,7 +188,8 @@ export function CreateClientForm({ action }: CreateClientFormProps) {
|
||||||
</FormDescription>
|
</FormDescription>
|
||||||
<FormMessage/>
|
<FormMessage/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}/>
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
|
@ -219,7 +209,8 @@ export function CreateClientForm({ action }: CreateClientFormProps) {
|
||||||
</FormDescription>
|
</FormDescription>
|
||||||
<FormMessage/>
|
<FormMessage/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}/>
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
|
@ -239,7 +230,8 @@ export function CreateClientForm({ action }: CreateClientFormProps) {
|
||||||
</FormDescription>
|
</FormDescription>
|
||||||
<FormMessage/>
|
<FormMessage/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}/>
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
|
@ -248,7 +240,7 @@ export function CreateClientForm({ action }: CreateClientFormProps) {
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Owner</FormLabel>
|
<FormLabel>Owner</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input placeholder="Identity ID" {...field} />
|
<Input placeholder="ACME INC" {...field} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormDescription>
|
<FormDescription>
|
||||||
Owner is a string identifying the owner of the OAuth 2.0 Client.
|
Owner is a string identifying the owner of the OAuth 2.0 Client.
|
||||||
|
|
Loading…
Add table
Reference in a new issue