Skip to content

Commit

Permalink
chore: fixed more redirects #283
Browse files Browse the repository at this point in the history
  • Loading branch information
srizvi committed Apr 27, 2024
1 parent fbedb0c commit 0e75da8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions apps/mai-sc/src/app/(chat)/chat/page.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 (
<AI initialAIState={{ chatId: id, messages: [] }}>
<Chat id={id} session={session} missingKeys={missingKeys} />
Expand Down
4 changes: 2 additions & 2 deletions apps/mai-sc/src/ui/chat-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export function ChatList({ messages, session, isShared }: ChatList) {
<div className="ml-4 flex-1 space-y-2 overflow-hidden px-1">
<p className="leading-normal text-muted-foreground">
Please{' '}
<Link href="/login" className="underline underline-offset-4">
<Link href="/login" className="font-semibold text-primary">
log in
</Link>{' '}
or{' '}
<Link href="/signup" className="underline underline-offset-4">
<Link href="/signup" className="font-semibold text-primary">
sign up
</Link>{' '}
to save and revisit your chat history.
Expand Down
2 changes: 1 addition & 1 deletion apps/mai-sc/src/ui/user-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function UserMenu({ user }: UserMenuProps) {
<form
action={async () => {
'use server';
await signOut();
await signOut({ redirectTo: '/login' });
}}
>
<button className=" relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-xs outline-none transition-colors hover:bg-destructive hover:text-white focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50">
Expand Down

0 comments on commit 0e75da8

Please sign in to comment.