-
Notifications
You must be signed in to change notification settings - Fork 2
/
auth.ts
35 lines (34 loc) · 1.2 KB
/
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 Credentials from "next-auth/providers/credentials";
import { authConfig } from "@/auth.config";
import { SupabaseAdapter } from "@auth/supabase-adapter";
import { customEmailProvider } from "@/lib/custom-email-provider";
import { authorizeCredentials } from "@/lib/authorize-credentials";
import { handleAuthRedirect } from "@/lib/handle-auth-redirect";
import { assignUserRole } from "@/lib/assign-user-role";
import { handleAuthJwt } from "@/lib/handle-auth-jwt";
import { handleAuthSession } from "@/lib/handle-auth-session";
export const { handlers, signIn, signOut, auth } = NextAuth({
...authConfig,
debug: false,
session: { strategy: "jwt" },
events: { createUser: assignUserRole },
callbacks: {
redirect: handleAuthRedirect,
jwt: handleAuthJwt,
session: handleAuthSession,
},
providers: [
Google({ allowDangerousEmailAccountLinking: true }),
customEmailProvider(),
Credentials({
authorize: authorizeCredentials,
}),
],
adapter: SupabaseAdapter({
url: process.env.SUPABASE_URL!,
secret: process.env.SUPABASE_SERVICE_ROLE_KEY!,
}),
pages: { error: "/auth-error" },
});