-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.config.ts
More file actions
28 lines (27 loc) · 870 Bytes
/
auth.config.ts
File metadata and controls
28 lines (27 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import GitHub from "@auth/core/providers/github";
import Google from "@auth/core/providers/google";
import { defineConfig } from "auth-astro";
import { db } from "@/db";
import * as userService from "@/lib/services/user-service";
export default defineConfig({
providers: [
GitHub({
clientId: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
}),
Google({
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
}),
],
callbacks: {
jwt: async ({ token, user, trigger }) => {
if (trigger === "signIn" && user?.email) {
// Find or create user in your DB
console.log("[jwt] New user sign in, finding or creating user");
await userService.findOrCreateUser(db, user.email, user.name || "");
}
return token;
},
},
});