37 lines
1012 B
TypeScript
37 lines
1012 B
TypeScript
import { cookies } from 'next/headers';
|
|
import { redirect } from 'next/navigation';
|
|
import { verifyToken } from '@/lib/auth';
|
|
import TerminalClient from '@/components/TerminalClient';
|
|
|
|
export default async function TerminalPage({ params }: { params: Promise<{ vmid: string }> }) {
|
|
const { vmid } = await params;
|
|
|
|
// Auth check
|
|
const cookieStore = await cookies();
|
|
const token = cookieStore.get('auth-token')?.value;
|
|
|
|
if (!token) {
|
|
redirect('/login');
|
|
}
|
|
|
|
const payload = verifyToken(token);
|
|
|
|
if (!payload) {
|
|
redirect('/login');
|
|
}
|
|
|
|
// Only allow VM 100
|
|
if (vmid !== '100') {
|
|
return (
|
|
<div className="min-h-screen bg-gray-900 text-white flex items-center justify-center">
|
|
<div className="text-center">
|
|
<h1 className="text-2xl font-bold mb-4">Access Denied</h1>
|
|
<p className="text-gray-400">Console access is only available for VM 100</p>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return <TerminalClient vmid={vmid} token={token} />;
|
|
}
|