diff --git a/apps/web/app/(admin)/admin/page.tsx b/apps/web/app/(admin)/admin/page.tsx
index 559c36f9..9585ea4b 100644
--- a/apps/web/app/(admin)/admin/page.tsx
+++ b/apps/web/app/(admin)/admin/page.tsx
@@ -3,16 +3,18 @@
import { useEffect } from "react";
import getSession from "@/lib/Authentication/JWT/getSession";
import { useRouter } from "next/navigation";
+import { useSession } from "@/components/Providers/AuthProvider";
export default function AdminPage() {
+ const { session } = useSession()
const { push } = useRouter();
useEffect(() => {
- const session = getSession();
+
if (session?.role !== "admin") {
push("/home");
}
- }, [push]);
+ }, [push, session?.role]);
return (
You are admin!
diff --git a/apps/web/app/(app)/artist/ArtistComponent.tsx b/apps/web/app/(app)/artist/ArtistComponent.tsx
index 49b13272..83819268 100644
--- a/apps/web/app/(app)/artist/ArtistComponent.tsx
+++ b/apps/web/app/(app)/artist/ArtistComponent.tsx
@@ -7,7 +7,6 @@ import ScrollButtons from "@/components/Home/ScrollButtons";
import PageGradient from "@/components/Layout/PageGradient";
import AlbumCard from "@/components/Music/Card/Album/AlbumCard";
import SongCard from "@/components/Music/Card/SongCard";
-import getSession from "@/lib/Authentication/JWT/getSession";
import { getArtistInfo } from "@music/sdk";
import { Album, Artist, LibrarySong } from "@music/sdk/types";
import { useSearchParams } from "next/navigation";
diff --git a/apps/web/app/(app)/history/page.tsx b/apps/web/app/(app)/history/page.tsx
index 81e5b442..ad5d3bfe 100644
--- a/apps/web/app/(app)/history/page.tsx
+++ b/apps/web/app/(app)/history/page.tsx
@@ -2,6 +2,7 @@
import SongCard from "@/components/Music/Card/SongCard";
+import { useSession } from "@/components/Providers/AuthProvider";
import getSession from "@/lib/Authentication/JWT/getSession";
import { getListenHistory, getSongInfo } from "@music/sdk";
import { LibrarySong } from "@music/sdk/types";
@@ -11,9 +12,10 @@ import { useEffect, useState } from "react";
export default function HistoryPage() {
const [listenHistorySongs, setListenHistorySongs] = useState([]);
+ const { session } = useSession()
+
useEffect(() => {
const fetchListenHistory = async () => {
- const session = getSession()
if (session) {
const listenHistoryItems = await getListenHistory(Number(session.sub));
@@ -25,7 +27,7 @@ export default function HistoryPage() {
};
fetchListenHistory();
- }, []);
+ }, [session]);
return (
<>
diff --git a/apps/web/app/(app)/layout.tsx b/apps/web/app/(app)/layout.tsx
index bc3b9362..90125715 100644
--- a/apps/web/app/(app)/layout.tsx
+++ b/apps/web/app/(app)/layout.tsx
@@ -4,6 +4,7 @@ import { Metadata, Viewport } from "next";
import MainLayout from "./main-layout";
import SplashScreen from "@/components/Layout/SplashScreen";
import { cn } from "@music/ui/lib/utils";
+import AuthProvider from "@/components/Providers/AuthProvider";
export const metadata: Metadata = {
applicationName: "ParsonLabs Music",
@@ -48,9 +49,13 @@ export default async function RootLayout({ children }: any) {
"min-h-screen bg-background font-sans antialiased bg-gray-900 texxt-white",
fontSans.variable
)}>
-
- {children}
-
+
+
+
+ {children}
+
+
+