-
Notifications
You must be signed in to change notification settings - Fork 3
/
auth.config.ts
43 lines (40 loc) · 1.14 KB
/
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
40
41
42
43
import GitHub, { GitHubProfile } from '@auth/core/providers/github';
import { NextAuthConfig } from 'next-auth';
import { Role, User } from '@prisma/client';
export default {
providers: [
GitHub({
profile: ({ name, email, avatar_url, html_url }: GitHubProfile) => {
let firstName = name ?? 'First Name',
lastName = '';
if (name && name.includes(' ')) [firstName, lastName] = name.split(' ');
return {
firstName,
lastName,
email,
phone: null,
school: null,
image: avatar_url,
role: Role.Hacker,
bio: null,
githubURL: html_url,
linkedinURL: null,
resumeUrl: null,
skills: [],
};
},
allowDangerousEmailAccountLinking: true,
}),
],
callbacks: {
jwt({ token, user, session, trigger }) {
if (trigger == 'update' && session?.user) token.user = session.user;
if (user) token.user = user;
return token;
},
async session({ session, token }) {
session.user = token.user as User;
return session;
},
},
} satisfies NextAuthConfig;