diff --git a/next.config.mjs b/next.config.mjs index 9f7ff0b..095a976 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -10,6 +10,7 @@ const config = { reactStrictMode: true, images: { domains: [ + "mixyboos.dev.fergl.ie", "cloudflare-ipfs.com", "avatars.githubusercontent.com", "mixyboos.twic.pics", diff --git a/src/app/(loggedin)/dashboard/layout.tsx b/src/app/(loggedin)/dashboard/layout.tsx index 89c0bb2..ecf3edd 100644 --- a/src/app/(loggedin)/dashboard/layout.tsx +++ b/src/app/(loggedin)/dashboard/layout.tsx @@ -1,5 +1,5 @@ "use client"; -import Sidebar from "@/lib/components/layout/sidebar/Sidebar"; +import Sidebar from "@/lib/components/layout/sidebar"; import Loading from "@/lib/components/widgets/Loading"; import { useSession } from "next-auth/react"; import React from "react"; @@ -8,9 +8,10 @@ const DashboardLayout = ({ children }: { children: React.ReactNode }) => { const { data: session } = useSession(); if (!session) return ; + return (
- +
{children}
); diff --git a/src/app/debug/page.tsx b/src/app/debug/page.tsx index 32c8eb4..898c6de 100644 --- a/src/app/debug/page.tsx +++ b/src/app/debug/page.tsx @@ -1,9 +1,10 @@ import Session from "@/lib/components/debug/Session"; +import { authOptions } from "@/lib/services/auth/config"; import { getServerSession } from "next-auth"; import React from "react"; const IndexPage = () => { - const session = getServerSession(); + const session = getServerSession(authOptions); return ; }; diff --git a/src/lib/components/layout/sidebar/index.ts b/src/lib/components/layout/sidebar/index.ts new file mode 100644 index 0000000..ae807db --- /dev/null +++ b/src/lib/components/layout/sidebar/index.ts @@ -0,0 +1,3 @@ +import Sidebar from "./sidebar"; + +export default Sidebar; diff --git a/src/lib/components/layout/sidebar/Sidebar.tsx b/src/lib/components/layout/sidebar/sidebar.tsx similarity index 96% rename from src/lib/components/layout/sidebar/Sidebar.tsx rename to src/lib/components/layout/sidebar/sidebar.tsx index ac2db23..0854f63 100644 --- a/src/lib/components/layout/sidebar/Sidebar.tsx +++ b/src/lib/components/layout/sidebar/sidebar.tsx @@ -15,14 +15,12 @@ import { CgSandClock } from "react-icons/cg"; import { BiCategoryAlt } from "react-icons/bi"; import Loading from "../../widgets/Loading"; import UserImage from "../../widgets/UserImage"; -import { type Session } from "next-auth"; +import { useSession } from "next-auth/react"; -type DashboardSidebarProps = { - session: Session | undefined; -}; - -const DashboardSidebar = ({ session }: DashboardSidebarProps) => { +const Sidebar = () => { const router = useRouter(); + const { data: session } = useSession(); + const _sidebarItemClick = (path: string | undefined): void => { if (!path) return; if (path.includes("dashboard")) { @@ -170,4 +168,4 @@ const DashboardSidebar = ({ session }: DashboardSidebarProps) => { ); }; -export default DashboardSidebar; +export default Sidebar; diff --git a/src/lib/services/auth/config.ts b/src/lib/services/auth/config.ts index 345045e..e6a81b3 100644 --- a/src/lib/services/auth/config.ts +++ b/src/lib/services/auth/config.ts @@ -22,7 +22,7 @@ export const authOptions: AuthOptions = { CredentialsProvider({ name: "Email and Password", credentials: { - userName: { + username: { label: "Username", type: "text", placeholder: "Username or email address", @@ -40,7 +40,7 @@ export const authOptions: AuthOptions = { return false; } const token = await new AuthService().getAuthToken( - credentials.userName, + credentials.username, credentials.password, ); @@ -82,6 +82,7 @@ export const authOptions: AuthOptions = { return true; }, async session({ session, token }) { + session.id = token.sub as string; session.user.accessToken = token.accessToken as string; session.user.displayName = token.displayName as string; session.user.profileImage = token.profileImage as string; diff --git a/src/types/next-auth.d.ts b/src/types/next-auth.d.ts index 50e2835..26a2a74 100644 --- a/src/types/next-auth.d.ts +++ b/src/types/next-auth.d.ts @@ -7,6 +7,7 @@ declare module "next-auth" { * Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context */ interface Session { + id: string; user: User; } interface User {