Skip to content

Commit b245705

Browse files
committed
fix: 我现在能看到数据库中有字段了
1 parent b2c806e commit b245705

File tree

7 files changed

+1476
-953
lines changed

7 files changed

+1476
-953
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,5 @@ Agents.md
5454
.env
5555

5656
# VS code
57-
.vscode
57+
.vscode
58+
/generated/prisma

auth.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ export const authConfig = {
1717

1818
return true;
1919
},
20+
async signIn({ user, account, profile }) {
21+
console.log("[auth] signIn payload", { user, account, profile });
22+
return true;
23+
},
24+
async session({ session, token }) {
25+
console.log("[auth] session payload", { session, token });
26+
return session;
27+
},
28+
async jwt({ token, user, account, profile }) {
29+
console.log("[auth] jwt payload", { token, user, account, profile });
30+
return token;
31+
},
2032
},
2133
providers: [
2234
GitHub({

auth.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
11
import NextAuth, { CredentialsSignin } from "next-auth";
22
import { authConfig } from "./auth.config";
33
import GitHub from "next-auth/providers/github";
4+
import { Pool } from "@neondatabase/serverless";
5+
import NeonAdapter from "@auth/neon-adapter";
46

57
class InvalidLoginError extends CredentialsSignin {
68
code = "Invalid identifier or password";
79
}
810

9-
export const { handlers, auth, signIn, signOut } = NextAuth({
10-
...authConfig,
11-
providers: [
12-
GitHub({
13-
profile(profile) {
14-
return {
15-
id: `github-${profile.id}`, // 让 User.id 直接对应 GitHub ID
16-
name: profile.name ?? profile.login,
17-
email: profile.email,
18-
image: profile.avatar_url,
19-
};
20-
},
21-
}),
22-
],
11+
export const { handlers, auth, signIn, signOut } = NextAuth(() => {
12+
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
13+
return {
14+
...authConfig,
15+
adapter: NeonAdapter(pool),
16+
providers: [
17+
GitHub({
18+
profile(profile) {
19+
return {
20+
id: `github-${profile.id}`, // 让 User.id 直接对应 GitHub ID
21+
name: profile.name ?? profile.login,
22+
email: profile.email,
23+
image: profile.avatar_url,
24+
};
25+
},
26+
}),
27+
],
28+
};
29+
session: {
30+
strategy: "database";
31+
}
2332
});

package.json

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616
"dependencies": {
1717
"@ai-sdk/google": "^2.0.14",
1818
"@ai-sdk/openai": "^2.0.32",
19-
"@ai-sdk/react": "^2.0.45",
20-
"@assistant-ui/react": "^0.11.10",
19+
"@ai-sdk/react": "^2.0.48",
20+
"@assistant-ui/react": "^0.11.14",
2121
"@assistant-ui/react-ai-sdk": "^1.1.0",
2222
"@assistant-ui/react-markdown": "^0.11.0",
23+
"@auth/neon-adapter": "^1.10.0",
2324
"@giscus/react": "^3.1.0",
2425
"@neondatabase/serverless": "^1.0.1",
25-
"@orama/orama": "^3.1.13",
26-
"@orama/tokenizers": "^3.1.13",
26+
"@orama/orama": "^3.1.14",
27+
"@orama/tokenizers": "^3.1.14",
28+
"@prisma/client": "^6.16.2",
2729
"@radix-ui/react-avatar": "^1.1.10",
2830
"@radix-ui/react-dialog": "^1.1.15",
2931
"@radix-ui/react-label": "^2.1.7",
@@ -32,35 +34,36 @@
3234
"@radix-ui/react-tooltip": "^1.2.8",
3335
"@types/mdx": "^2.0.13",
3436
"@vercel/speed-insights": "^1.2.0",
35-
"ai": "^5.0.45",
36-
"antd": "^5.27.3",
37+
"ai": "^5.0.48",
38+
"antd": "^5.27.4",
3739
"class-variance-authority": "^0.7.1",
3840
"clsx": "^2.1.1",
3941
"cmdk": "^1.1.1",
40-
"fumadocs-core": "^15.7.11",
41-
"fumadocs-mdx": "^11.9.1",
42-
"fumadocs-ui": "^15.7.11",
42+
"fumadocs-core": "^15.7.13",
43+
"fumadocs-mdx": "^11.10.1",
44+
"fumadocs-ui": "^15.7.13",
4345
"lucide-react": "^0.544.0",
44-
"motion": "^12.23.14",
46+
"motion": "^12.23.16",
4547
"next": "^15.5.3",
4648
"next-auth": "5.0.0-beta.29",
47-
"next-intl": "^4.3.8",
49+
"next-intl": "^4.3.9",
50+
"prisma": "^6.16.2",
4851
"react": "^19.1.1",
4952
"react-dom": "^19.1.1",
5053
"rehype-autolink-headings": "^7.1.0",
5154
"rehype-slug": "^6.0.0",
5255
"remark-gfm": "^4.0.1",
5356
"tailwind-merge": "^3.3.1",
54-
"zod": "^4.1.9",
57+
"zod": "^4.1.11",
5558
"zustand": "^5.0.8"
5659
},
5760
"devDependencies": {
5861
"@tailwindcss/postcss": "^4.1.13",
5962
"@types/node": "latest",
60-
"@types/react": "^19.1.12",
63+
"@types/react": "^19.1.13",
6164
"@types/react-dom": "^19.1.9",
6265
"autoprefixer": "^10.4.21",
63-
"eslint": "^9.35.0",
66+
"eslint": "^9.36.0",
6467
"eslint-config-next": "^15.5.3",
6568
"husky": "^9.1.7",
6669
"katex": "^0.16.22",
@@ -71,7 +74,7 @@
7174
"remark-math": "^6.0.0",
7275
"tailwindcss": "^4.1.13",
7376
"tw-animate-css": "^1.3.8",
74-
"typescript": "^5.6.3",
77+
"typescript": "^5.9.2",
7578
"vercel": "^48.1.0"
7679
},
7780
"lint-staged": {

0 commit comments

Comments
 (0)