Skip to content

Commit

Permalink
Merge pull request #202 from lalitdotdev/feature/creator-launchpad-hub
Browse files Browse the repository at this point in the history
fix(Navbar): Prevent server actions for unauthenticated users
  • Loading branch information
lalitdotdev authored Oct 11, 2024
2 parents 67566e0 + 623593c commit 7181a57
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@ import { getServerSession } from "next-auth";

const Navbar = async () => {
const session = await getServerSession(authOptions);
const notifications = await getNotifications();
const products = await getProductsByUserId(session?.user?.id || "");
const isPremium = await isUserPremium();

let notifications: any[] = [];
let products: any[] = [];
let isPremium: any = false;

if (session?.user?.id) {
// Only fetch data if the user is logged in
notifications = await getNotifications() ?? [];
products = await getProductsByUserId(session.user.id) ?? [];
isPremium = await isUserPremium();
}

return (
<nav className="fixed top-0 w-full z-10 bg-[#1B1F23] border-b-2 border-zinc-800 backdrop-blur-lg">
Expand Down

0 comments on commit 7181a57

Please sign in to comment.