diff --git a/app/api/auth/[...nextauth]/route.ts b/app/api/auth/[...nextauth]/route.ts new file mode 100644 index 0000000..200784e --- /dev/null +++ b/app/api/auth/[...nextauth]/route.ts @@ -0,0 +1,50 @@ + +import NextAuth, { NextAuthOptions } from "next-auth"; +import KeycloakProvider from "next-auth/providers/keycloak"; + + +export const authOptions: NextAuthOptions = { + providers: [ + KeycloakProvider({ + clientId: process.env.KEYCLOAK_CLIENT_ID!, + clientSecret: process.env.KEYCLOAK_CLIENT_SECRET!, + issuer: process.env.KEYCLOAK_ISSUER!, + }), + ], + + secret: process.env.NEXTAUTH_SECRET, + callbacks: { + async jwt({ token, account, profile }) { + console.log("PROFILE =>", profile) + + if (account && profile) { + token.name = + (profile as any).name || + (profile as any).preferred_username || + "Unknown User" + + token.email = (profile as any).email || "no-email" + } + + console.log("TOKEN =>", token) + return token + }, + + async session({ session, token }) { + session.user = { + ...session.user, + name: token.name as string, + email: token.email as string, + } + + console.log("SESSION =>", session) + return session + }, + }, + + debug: true, +}; + +const handler = NextAuth(authOptions); + +export { handler as GET, handler as POST }; \ No newline at end of file diff --git a/app/dashboard/overview/serviceEngineer/page.tsx b/app/dashboard/overview/serviceEngineer/page.tsx index e69de29..0bbae64 100644 --- a/app/dashboard/overview/serviceEngineer/page.tsx +++ b/app/dashboard/overview/serviceEngineer/page.tsx @@ -0,0 +1,14 @@ +"use client"; + +import ServiceEngineerPortal from "@/components/dashboard/serviceEngineer"; + +export default function EngagementDashboard() { + return ( + + +