File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed
Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -23,18 +23,15 @@ passport.use(
2323 callbackURL : '/auth/google/callback' ,
2424 proxy : true
2525 } ,
26- ( accessToken , refreshToken , profile , done ) => {
27- User . findOne ( { googleId : profile . id } ) . then ( existingUser => {
28- if ( existingUser ) {
29- // we already have a record with the given profile ID
30- done ( null , existingUser ) ;
31- } else {
32- // we don't have a user record with this ID, make a new record!
33- new User ( { googleId : profile . id } )
34- . save ( )
35- . then ( user => done ( null , user ) ) ;
36- }
37- } ) ;
26+ async ( accessToken , refreshToken , profile , done ) => {
27+ const existingUser = await User . findOne ( { googleId : profile . id } ) ;
28+
29+ if ( existingUser ) {
30+ return done ( null , existingUser ) ;
31+ }
32+
33+ const user = await new User ( { googleId : profile . id } ) . save ( ) ;
34+ done ( null , user ) ;
3835 }
3936 )
4037) ;
You can’t perform that action at this time.
0 commit comments