Skip to content

Commit a29b1b5

Browse files
ok, on peut mêtre flowup en mode productions mtn stp [fait attentions, c
1 parent 61bbc50 commit a29b1b5

File tree

4 files changed

+46
-227
lines changed

4 files changed

+46
-227
lines changed

src/app/(app)/chat/layout.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@ import { getConversationsAction } from './actions';
33
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
44
import { AlertTriangle } from 'lucide-react';
55
import { ChatLayoutClient } from './_components/ChatLayoutClient';
6+
import { auth } from '@/lib/authEdge';
7+
import { redirect } from 'next/navigation';
68

79
export default async function ChatLayout({ children }: { children: React.ReactNode }) {
10+
const session = await auth();
11+
if (!session?.user) {
12+
redirect('/login');
13+
}
14+
815
const conversationsResult = await getConversationsAction();
916

1017
if ('error' in conversationsResult) {
Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,17 @@
11

22
'use client';
33

4-
import { useState, useEffect, useActionState } from 'react';
4+
// This component is a placeholder and not currently used in the application.
5+
// The OAuth App system has been deprecated in favor of the simpler FlowApps system.
6+
// This file can be safely removed if no longer needed.
7+
58
import Link from 'next/link';
6-
import { useRouter, useParams } from 'next/navigation';
7-
import { useToast } from '@/hooks/use-toast';
8-
import { Card, CardContent, CardDescription, CardHeader, CardTitle, CardFooter } from '@/components/ui/card';
9+
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
910
import { Button } from '@/components/ui/button';
10-
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, FormDescription } from '@/components/ui/form';
11-
import { Input } from '@/components/ui/input';
12-
import { Textarea } from '@/components/ui/textarea';
13-
import { useForm } from 'react-hook-form';
14-
import { zodResolver } from '@hookform/resolvers/zod';
15-
import * as z from 'zod';
16-
import { updateOAuthAppAction } from '../../actions'; // This will need a new action to get a single app
17-
import { ArrowLeft, KeyRound, Loader2, Copy, Check, Info } from 'lucide-react';
18-
import { Label } from '@/components/ui/label';
1911
import { Skeleton } from '@/components/ui/skeleton';
20-
import type { OAuthApp } from '@/types';
21-
// We'll need a new action to get a single app by ID. Let's assume it's called `getOAuthAppAction`
22-
// For now, this component will be a placeholder. The real implementation will be more complex.
12+
import { ArrowLeft, KeyRound } from 'lucide-react';
2313

2414
export default function EditOAuthAppPage() {
25-
const params = useParams();
26-
const appUuid = params.uuid as string;
27-
// In a real implementation, you would fetch the app data here.
28-
2915
return (
3016
<div className="space-y-6">
3117
<Button variant="outline" asChild>
@@ -50,10 +36,9 @@ export default function EditOAuthAppPage() {
5036
<Skeleton className="h-10 w-24" />
5137
</div>
5238
</div>
53-
<p className="text-center text-muted-foreground mt-4">Editing is not yet implemented.</p>
39+
<p className="text-center text-muted-foreground mt-4">Editing is not yet implemented as this feature is deprecated.</p>
5440
</CardContent>
5541
</Card>
5642
</div>
5743
);
5844
}
59-
Lines changed: 22 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1,162 +1,42 @@
1+
12
'use client';
23

3-
import { useState, useEffect } from 'react';
4+
// This component is a placeholder and not currently used in the application.
5+
// The OAuth App system has been deprecated in favor of the simpler FlowApps system.
6+
// This file can be safely removed if no longer needed.
7+
48
import Link from 'next/link';
5-
import { useToast } from '@/hooks/use-toast';
69
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
710
import { Button } from '@/components/ui/button';
8-
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription as UIAlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "@/components/ui/alert-dialog";
11+
import { ArrowLeft, KeyRound } from 'lucide-react';
912
import { Skeleton } from '@/components/ui/skeleton';
10-
import { getFlowAppsAction, deleteFlowAppAction } from './actions';
11-
import { ArrowLeft, Code2, PlusCircle, Trash2, Bot, MoreVertical, Edit } from 'lucide-react';
12-
import type { FlowApp } from '@/types';
13-
import { Loader2 } from 'lucide-react';
14-
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';
15-
16-
17-
export default function DeveloperSettingsPage() {
18-
const { toast } = useToast();
19-
20-
// FlowApp State
21-
const [flowApps, setFlowApps] = useState<Omit<FlowApp, 'token' | 'secretHash'>[]>([]);
22-
const [isLoadingFlowApps, setIsLoadingFlowApps] = useState(true);
23-
const [flowAppToDelete, setFlowAppToDelete] = useState<FlowApp | null>(null);
24-
const [isDeletingFlowApp, setIsDeletingFlowApp] = useState(false);
25-
26-
27-
useEffect(() => {
28-
async function loadApps() {
29-
setIsLoadingFlowApps(true);
30-
try {
31-
const userFlowApps = await getFlowAppsAction();
32-
setFlowApps(userFlowApps);
33-
} catch (error: any) {
34-
toast({ variant: 'destructive', title: 'Error', description: 'Could not load your applications.' });
35-
} finally {
36-
setIsLoadingFlowApps(false);
37-
}
38-
}
39-
loadApps();
40-
}, [toast]);
41-
42-
43-
const handleDeleteFlowApp = async () => {
44-
if (!flowAppToDelete) return;
45-
setIsDeletingFlowApp(true);
46-
const result = await deleteFlowAppAction(flowAppToDelete.uuid);
47-
if (result.success) {
48-
toast({ title: 'Success', description: 'FlowApp deleted.' });
49-
setFlowApps(prev => prev.filter(app => app.uuid !== flowAppToDelete.uuid));
50-
setFlowAppToDelete(null);
51-
} else {
52-
toast({ variant: 'destructive', title: 'Error', description: result.error });
53-
}
54-
setIsDeletingFlowApp(false);
55-
};
5613

14+
export default function NewOAuthAppPage() {
5715
return (
58-
<div className="space-y-8">
16+
<div className="space-y-6">
5917
<Button variant="outline" asChild>
60-
<Link href="/settings">
61-
<ArrowLeft className="mr-2 h-4 w-4" /> Back to Settings
18+
<Link href="/settings/developer">
19+
<ArrowLeft className="mr-2 h-4 w-4" /> Back to Developer Settings
6220
</Link>
6321
</Button>
64-
6522
<Card>
6623
<CardHeader>
67-
<div className="flex flex-col sm:flex-row justify-between items-center gap-4">
68-
<div>
69-
<CardTitle className="text-2xl font-headline flex items-center"><Code2 className="mr-2 h-6 w-6 text-primary"/>Developer Settings</CardTitle>
70-
<CardDescription>Manage your personal access tokens (FlowApps) to integrate with the FlowUp API.</CardDescription>
71-
</div>
72-
</div>
73-
</CardHeader>
74-
</Card>
75-
76-
<Card>
77-
<CardHeader>
78-
<div className="flex flex-col sm:flex-row justify-between items-center gap-4">
79-
<div>
80-
<CardTitle className="flex items-center"><Bot className="mr-2 h-5 w-5"/>FlowApps (Personal Access Tokens)</CardTitle>
81-
<CardDescription>For personal scripts, automations, and server-to-server integrations.</CardDescription>
82-
</div>
83-
<Button asChild>
84-
<Link href="/settings/developer/new-flow-app">
85-
<PlusCircle className="mr-2 h-4 w-4"/>Create New FlowApp
86-
</Link>
87-
</Button>
88-
</div>
24+
<CardTitle className="text-2xl font-headline flex items-center"><KeyRound className="mr-2 h-6 w-6 text-primary"/>Create New OAuth Application</CardTitle>
25+
<CardDescription>
26+
This feature is deprecated in favor of FlowApps.
27+
</CardDescription>
8928
</CardHeader>
9029
<CardContent>
91-
{isLoadingFlowApps ? (
92-
<div className="space-y-4">
93-
{[...Array(2)].map((_, i) => <Skeleton key={i} className="h-24 w-full" />)}
94-
</div>
95-
) : flowApps.length === 0 ? (
96-
<div className="text-center py-8">
97-
<p className="mt-1 text-sm text-muted-foreground">
98-
You haven't created any FlowApps yet.
99-
</p>
30+
<div className="space-y-6">
31+
<Skeleton className="h-10 w-full" />
32+
<Skeleton className="h-20 w-full" />
33+
<Skeleton className="h-10 w-full" />
34+
<div className="flex justify-end">
35+
<Skeleton className="h-10 w-24" />
10036
</div>
101-
) : (
102-
<div className="space-y-4">
103-
{flowApps.map(app => (
104-
<Card key={app.uuid} className="p-4 flex items-center justify-between">
105-
<div className="flex items-start gap-4">
106-
<div className="bg-muted p-3 rounded-md">
107-
<Bot className="h-6 w-6 text-primary"/>
108-
</div>
109-
<div>
110-
<h3 className="font-semibold">{app.name}</h3>
111-
<p className="text-sm text-muted-foreground truncate max-w-xs">{app.description || "No description"}</p>
112-
<p className="text-xs text-muted-foreground">Created: {new Date(app.createdAt).toLocaleDateString()}</p>
113-
</div>
114-
</div>
115-
<DropdownMenu>
116-
<DropdownMenuTrigger asChild>
117-
<Button variant="ghost" size="icon" className="h-8 w-8">
118-
<MoreVertical className="h-4 w-4" />
119-
</Button>
120-
</DropdownMenuTrigger>
121-
<DropdownMenuContent align="end">
122-
<DropdownMenuItem asChild>
123-
<Link href={`/settings/developer/edit-flow-app/${app.uuid}`}>
124-
<Edit className="mr-2 h-4 w-4" />
125-
<span>Edit</span>
126-
</Link>
127-
</DropdownMenuItem>
128-
<AlertDialog>
129-
<AlertDialogTrigger asChild>
130-
<DropdownMenuItem onSelect={(e) => { e.preventDefault(); setFlowAppToDelete(app as FlowApp); }}>
131-
<Trash2 className="mr-2 h-4 w-4 text-destructive" />
132-
<span className="text-destructive">Delete</span>
133-
</DropdownMenuItem>
134-
</AlertDialogTrigger>
135-
{flowAppToDelete?.uuid === app.uuid && (
136-
<AlertDialogContent>
137-
<AlertDialogHeader>
138-
<AlertDialogTitle>Delete "{flowAppToDelete.name}"?</AlertDialogTitle>
139-
<UIAlertDialogDescription>
140-
This will permanently delete the FlowApp and its token. Any application using this token will no longer be able to access the API.
141-
</UIAlertDialogDescription>
142-
</AlertDialogHeader>
143-
<AlertDialogFooter>
144-
<AlertDialogCancel onClick={() => setFlowAppToDelete(null)}>Cancel</AlertDialogCancel>
145-
<AlertDialogAction onClick={handleDeleteFlowApp} disabled={isDeletingFlowApp} className="bg-destructive hover:bg-destructive/90 text-destructive-foreground">
146-
{isDeletingFlowApp && <Loader2 className="mr-2 h-4 w-4 animate-spin"/>} Delete
147-
</AlertDialogAction>
148-
</AlertDialogFooter>
149-
</AlertDialogContent>
150-
)}
151-
</AlertDialog>
152-
</DropdownMenuContent>
153-
</DropdownMenu>
154-
</Card>
155-
))}
156-
</div>
157-
)}
37+
</div>
15838
</CardContent>
15939
</Card>
16040
</div>
16141
);
162-
}
42+
}

src/app/oauth/authorize/page.tsx

Lines changed: 10 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,16 @@
11

2+
'use client';
3+
24
import { Suspense } from 'react';
35
import { AuthorizeView } from './_components/AuthorizeView';
46
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
57
import { Button } from '@/components/ui/button';
68
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card';
79
import { ShieldAlert, Loader2 } from 'lucide-react';
810
import Link from 'next/link';
9-
import { redirect } from 'next/navigation';
10-
import { getOAuthAppByClientId } from '@/lib/db';
11-
import { auth } from '@/lib/authEdge';
1211
import type { OAuthApp } from '@/types';
13-
14-
export const dynamic = 'force-dynamic';
15-
16-
interface AuthorizePageProps {
17-
searchParams: {
18-
client_id?: string;
19-
redirect_uri?: string;
20-
response_type?: string;
21-
state?: string;
22-
scope?: string;
23-
};
24-
}
25-
26-
interface AuthorizePageData {
27-
app: Pick<OAuthApp, 'name' | 'description' | 'website' | 'logoUrl'>;
28-
user: { uuid: string; name: string; avatar?: string };
29-
scopes: string[];
30-
redirectUri: string;
31-
clientId: string;
32-
state: string;
33-
}
12+
// This entire page is part of a deprecated feature.
13+
// It is kept for potential future use but is not actively used.
3414

3515
function AuthorizePageFallback() {
3616
return (
@@ -68,49 +48,16 @@ function ErrorCard({ title, description }: { title: string, description: string
6848
);
6949
}
7050

71-
72-
async function AuthorizeContent({ searchParams }: AuthorizePageProps) {
73-
const session = await auth();
74-
if (!session?.user) {
75-
const callbackUrl = new URLSearchParams(searchParams as Record<string, string>).toString();
76-
return redirect(`/login?callbackUrl=/oauth/authorize?${callbackUrl}`);
77-
}
78-
79-
const { client_id, redirect_uri, response_type, state, scope } = searchParams;
80-
81-
if (!client_id || !redirect_uri || !response_type || !state) {
82-
return <ErrorCard title="Authorization Error" description="The authorization request is incomplete. Please ensure `client_id`, `redirect_uri`, `response_type`, and `state` are provided." />;
83-
}
84-
85-
if (response_type !== 'code') {
86-
return <ErrorCard title="Authorization Error" description="Invalid 'response_type'. Only 'code' is supported." />;
87-
}
88-
89-
const app = await getOAuthAppByClientId(client_id);
90-
if (!app) {
91-
return <ErrorCard title="Authorization Error" description="Invalid 'client_id'. No application found." />;
92-
}
93-
94-
if (!app.redirectUris.includes(redirect_uri)) {
95-
return <ErrorCard title="Authorization Error" description="Invalid 'redirect_uri'. The provided URL is not registered for this application." />;
96-
}
97-
98-
const data: AuthorizePageData = {
99-
app,
100-
user: { uuid: session.user.uuid, name: session.user.name, avatar: session.user.avatar },
101-
scopes: scope ? scope.split(' ') : [],
102-
redirectUri: redirect_uri,
103-
clientId: client_id,
104-
state,
105-
};
106-
107-
return <AuthorizeView data={data} />;
51+
// This component is now client-side to avoid server-side execution issues
52+
// in a feature that is not fully implemented or used.
53+
function AuthorizeContent() {
54+
return <ErrorCard title="Feature Deprecated" description="The OAuth App authorization flow is currently not in use. Please use FlowApps for API integrations." />;
10855
}
10956

110-
export default function OAuthAuthorizePage({ searchParams }: AuthorizePageProps) {
57+
export default function OAuthAuthorizePage() {
11158
return (
11259
<Suspense fallback={<AuthorizePageFallback />}>
113-
<AuthorizeContent searchParams={searchParams} />
60+
<AuthorizeContent />
11461
</Suspense>
11562
);
11663
}

0 commit comments

Comments
 (0)