Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c063d5d

Browse files
committed
Prefill user data with the data that we get from GitHubb
1 parent 432f510 commit c063d5d

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

src/adapters/fauna/clear-db.mjs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,16 @@ async function main() {
3838
q.Map(
3939
q.Paginate(q.Documents(q.Collection('goal_updates'))),
4040
(goalUpdate) => q.Delete(goalUpdate)
41-
)
42-
q.Map(
43-
q.Paginate(q.Documents(q.Collection('goal_likes'))),
44-
(goalUpdate) => q.Delete(goalUpdate)
45-
)
41+
),
42+
q.Map(q.Paginate(q.Documents(q.Collection('goal_likes'))), (goalLike) =>
43+
q.Delete(goalLike)
44+
),
4645
q.Map(
4746
q.Paginate(q.Documents(q.Collection('update_comments'))),
48-
(goalUpdate) => q.Delete(goalUpdate)
47+
(goalComment) => q.Delete(goalComment)
4948
)
5049
)
5150
)
5251
}
5352

54-
main()
53+
main().catch((e) => console.error(e))

src/adapters/fauna/index.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,20 @@ const Adapter = (config, options = {}) => {
3838

3939
const FQL = q.Create(q.Collection(collections.User), {
4040
data: {
41-
name: profile.name,
4241
email: profile.email,
4342
image: profile.image,
43+
account: {
44+
firstName: profile.name,
45+
bio: profile.bio,
46+
},
47+
socials: {
48+
github: profile.github,
49+
twitter: profile.twitter,
50+
blog: profile.blog,
51+
},
52+
otherDetails: {
53+
company: profile.company,
54+
},
4455
emailVerified: profile.emailVerified
4556
? q.Time(profile.emailVerified.toISOString())
4657
: null,
@@ -149,9 +160,20 @@ const Adapter = (config, options = {}) => {
149160

150161
const FQL = q.Update(q.Ref(q.Collection(collections.User), user.id), {
151162
data: {
152-
name: user.name,
153163
email: user.email,
154164
image: user.image,
165+
account: {
166+
firstName: user.name,
167+
bio: user.bio,
168+
},
169+
socials: {
170+
github: user.github,
171+
twitter: user.twitter,
172+
blog: user.blog,
173+
},
174+
otherDetails: {
175+
company: user.company,
176+
},
155177
emailVerified: user.emailVerified
156178
? q.Time(user.emailVerified.toISOString())
157179
: null,

src/pages/api/auth/[...nextauth].ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ const options: InitOptions = {
3131
email: profileData.email,
3232
image: profileData.avatar_url,
3333
username: profileData.login,
34+
bio: profileData.bio,
35+
github: profileData.login,
36+
twitter: profileData.twitter_username,
37+
blog: profileData.blog,
38+
company: profileData.company,
3439
}
3540
},
3641
}),
@@ -69,6 +74,11 @@ const options: InitOptions = {
6974
email: null,
7075
image: profileImage,
7176
username,
77+
bio: null,
78+
github: null,
79+
twitter: null,
80+
blog: null,
81+
company: null,
7282
}
7383
},
7484
}),

0 commit comments

Comments
 (0)