Index: auth.config.ts
===================================================================
--- auth.config.ts	(revision 41ea2cb8495988ee663f2ffda06ffc54a07e88cb)
+++ auth.config.ts	(revision 1e532d034941986f20aff584766d61d3b60070ab)
@@ -5,4 +5,31 @@
         signIn: '/login',
     },
+    callbacks: {
+        async jwt({ token, user }) {
+            if (user) {
+                token.id = user.id;
+            }
+            return token;
+        },
+
+        async session({ session, token }) {
+            if (session.user && token.id) {
+                session.user.id = token.id as string;
+            }
+            return session;
+        },
+
+        authorized({ auth, request: { nextUrl } }) {
+            const isLoggedIn = !!auth?.user;
+            const isOnApp = nextUrl.pathname.startsWith('/home');
+
+            if (isOnApp && !isLoggedIn) return false;
+            if (!isOnApp && isLoggedIn && nextUrl.pathname.startsWith('/login')) {
+                return Response.redirect(new URL('/home', nextUrl));
+            }
+
+            return true;
+        },
+    },
     providers: [],
 } satisfies NextAuthConfig;
Index: auth.d.ts
===================================================================
--- auth.d.ts	(revision 41ea2cb8495988ee663f2ffda06ffc54a07e88cb)
+++ auth.d.ts	(revision 1e532d034941986f20aff584766d61d3b60070ab)
@@ -15,3 +15,7 @@
         email: string;
     }
+
+    interface JWT {
+        id: string;
+    }
 }
Index: auth.ts
===================================================================
--- auth.ts	(revision 41ea2cb8495988ee663f2ffda06ffc54a07e88cb)
+++ auth.ts	(revision 1e532d034941986f20aff584766d61d3b60070ab)
@@ -35,5 +35,11 @@
 
                     const passwordsMatch = await bcrypt.compare(password, user.password);
-                    if (passwordsMatch) return user;
+                    if (passwordsMatch) {
+                        return {
+                            id: user.id,
+                            name: user.name,
+                            email: user.email,
+                        };
+                    }
                 }
 
