diff --git a/apps/mai-sc/src/app/(chat)/chat/page.tsx b/apps/mai-sc/src/app/(chat)/chat/page.tsx index eed7d9cd3..c41538557 100644 --- a/apps/mai-sc/src/app/(chat)/chat/page.tsx +++ b/apps/mai-sc/src/app/(chat)/chat/page.tsx @@ -1,6 +1,8 @@ import type { Session } from '#/lib/types'; import type { Metadata } from 'next'; +import { redirect } from 'next/navigation'; + import { auth } from 'auth'; import { getMissingKeys } from '#/app/actions'; @@ -14,6 +16,10 @@ export default async function IndexPage() { const session = (await auth()) as Session; const missingKeys = await getMissingKeys(); + if (!session?.user) { + redirect(`/login`); + } + return ( diff --git a/apps/mai-sc/src/ui/chat-list.tsx b/apps/mai-sc/src/ui/chat-list.tsx index f4c162f4d..c571f4b67 100644 --- a/apps/mai-sc/src/ui/chat-list.tsx +++ b/apps/mai-sc/src/ui/chat-list.tsx @@ -28,11 +28,11 @@ export function ChatList({ messages, session, isShared }: ChatList) {

Please{' '} - + log in {' '} or{' '} - + sign up {' '} to save and revisit your chat history. diff --git a/apps/mai-sc/src/ui/user-menu.tsx b/apps/mai-sc/src/ui/user-menu.tsx index a3c3ea352..66b060f26 100644 --- a/apps/mai-sc/src/ui/user-menu.tsx +++ b/apps/mai-sc/src/ui/user-menu.tsx @@ -46,7 +46,7 @@ export function UserMenu({ user }: UserMenuProps) {

{ 'use server'; - await signOut(); + await signOut({ redirectTo: '/login' }); }} >