diff --git a/web/src/app/api/auth/[...nextauth]/route.ts b/web/src/app/api/auth/[...nextauth]/route.ts
index b376518..7eb9725 100644
--- a/web/src/app/api/auth/[...nextauth]/route.ts
+++ b/web/src/app/api/auth/[...nextauth]/route.ts
@@ -2,7 +2,9 @@ import { createAppClient, viemConnector } from "@farcaster/auth-client";
import NextAuth from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials";
-const auth = NextAuth({
+import { getProfile } from '../../../../lib/services/user';
+
+export const authOptions = {
providers: [
CredentialsProvider({
name: "Sign in with Farcaster",
@@ -20,15 +22,6 @@ const auth = NextAuth({
csrfToken: {
type: "text",
},
- // In a production app with a server, these should be fetched from
- // your Farcaster data indexer rather than have them accepted as part
- // of credentials.
- name: {
- type: "text",
- },
- pfp: {
- type: "text",
- },
},
async authorize(credentials) {
const appClient = createAppClient({
@@ -50,13 +43,20 @@ const auth = NextAuth({
return {
id: fid.toString(),
- name: credentials?.name,
- image: credentials?.pfp,
};
},
}),
],
-});
+ callbacks: {
+ async session({ session, token }) {
+ const profile = await getProfile({ fid: token.sub });
+ session.user = profile;
+ return session;
+ },
+ },
+};
+
+const auth = NextAuth(authOptions);
export const GET = auth;
export const POST = auth;
diff --git a/web/src/app/page.tsx b/web/src/app/page.tsx
index ad6e192..f64c30c 100644
--- a/web/src/app/page.tsx
+++ b/web/src/app/page.tsx
@@ -1,13 +1,21 @@
-// import { getServerSession } from 'next-auth';
+import { FeedPage } from '@components/feed/FeedPage';
+import { LandingPage } from '@components/landing/LandingPage';
+import { getServerSession } from 'next-auth';
-import { FeedPage } from "@components/feed/FeedPage";
-import { LandingPage } from "@components/landing/LandingPage";
+import { authOptions } from './api/auth/[...nextauth]/route';
export default async function Home() {
- // const session = await getServerSession();
- // if (session) {
- return