Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to browse before having to signup/login #278

Merged
merged 8 commits into from
Jul 13, 2024
Prev Previous commit
Next Next commit
feat: on conversations, redirect to login if the user is not logged in
  • Loading branch information
mnixo committed Jul 5, 2024
commit 54d411475bc933836caed369d655fc821104e469
7 changes: 5 additions & 2 deletions app/(dashboard)/conversations/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

import ConversationsWrapper from '@/components/messaging/ConversationWrapper';
import newServerClient from '@/supabase/utils/newServerClient';
import { redirect } from 'next/navigation';

const Conversations = async () => {
const supabase = newServerClient();
const {
data: { user },
} = await supabase.auth.getUser();
const userId = user?.id;

return userId && <ConversationsWrapper userId={userId} />;
if (!userId) {
redirect('/login');
}
return <ConversationsWrapper userId={userId} />;
};

export default Conversations;