-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.config.ts
39 lines (36 loc) · 920 Bytes
/
auth.config.ts
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
29
30
31
32
33
34
35
36
37
38
39
import { defineConfig } from "auth-astro";
import Google from "@auth/core/providers/google";
import { checkValidUser, registerUser } from "@/lib/supabase/function";
export default defineConfig({
session: {
strategy: "jwt",
},
secret: import.meta.env.AUTH_SECRET,
providers: [
Google({
clientId: import.meta.env.GOOGLE_OAUTH_CLIENT_ID,
clientSecret: import.meta.env.GOOGLE_OAUTH_SECRET,
}),
],
callbacks: {
async jwt({ token, account, user }: any) {
if (account?.provider === "google") {
const checkUser = await checkValidUser(user.email);
if (!checkUser.status) {
await registerUser({
email: user.email,
name: user.name,
image: user.image,
});
}
}
return token;
},
async session({ session }) {
return session;
},
},
pages: {
signIn: "/signin",
},
});