forked from krishaamer/ziran-generative-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.ts
35 lines (32 loc) · 934 Bytes
/
auth.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
import NextAuth from "next-auth";
import Google from "next-auth/providers/google";
import type { NextAuthConfig } from "next-auth";
export const config = {
theme: { logo: "https://authjs.dev/img/logo-sm.png" },
providers: [
Google({
clientId: process.env.AUTH_GOOGLE_ID,
clientSecret: process.env.AUTH_GOOGLE_SECRET,
authorization: {
params: {
prompt: "consent",
access_type: "offline",
response_type: "code",
},
},
}),
],
basePath: "/api/auth",
callbacks: {
authorized({ request, auth }) {
const { pathname } = request.nextUrl;
if (pathname === "/test") return !!auth;
return true;
},
jwt({ token, trigger, session }) {
if (trigger === "update") token.name = session.user.name;
return token;
},
},
} satisfies NextAuthConfig;
export const { handlers, signIn, signOut, auth } = NextAuth(config);