File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -17,11 +17,6 @@ const discordLogin = async () =>
17
17
const email = profile . email ;
18
18
const discordId = profile . id ;
19
19
20
- const oldUser = await User . findOne ( { email } ) ;
21
- if ( oldUser ) {
22
- return cb ( null , oldUser ) ;
23
- }
24
-
25
20
let avatarURL ;
26
21
if ( profile . avatar ) {
27
22
const format = profile . avatar . startsWith ( 'a_' ) ? 'gif' : 'png' ;
@@ -31,6 +26,13 @@ const discordLogin = async () =>
31
26
avatarURL = `https://cdn.discordapp.com/embed/avatars/${ defaultAvatarNum } .png` ;
32
27
}
33
28
29
+ const oldUser = await User . findOne ( { email } ) ;
30
+ if ( oldUser ) {
31
+ oldUser . avatar = avatarURL ;
32
+ await oldUser . save ( ) ;
33
+ return cb ( null , oldUser ) ;
34
+ }
35
+
34
36
const newUser = await User . create ( {
35
37
provider : 'discord' ,
36
38
discordId,
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ const githubLogin = async () =>
23
23
24
24
const oldUser = await User . findOne ( { email } ) ;
25
25
if ( oldUser ) {
26
+ oldUser . avatar = profile . photos [ 0 ] . value ;
27
+ await oldUser . save ( ) ;
26
28
return cb ( null , oldUser ) ;
27
29
}
28
30
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ const googleLogin = async () =>
17
17
try {
18
18
const oldUser = await User . findOne ( { email : profile . emails [ 0 ] . value } ) ;
19
19
if ( oldUser ) {
20
+ oldUser . avatar = profile . photos [ 0 ] . value ;
21
+ await oldUser . save ( ) ;
20
22
return cb ( null , oldUser ) ;
21
23
}
22
24
} catch ( err ) {
You can’t perform that action at this time.
0 commit comments