1
1
'use strict' ;
2
2
3
3
var passport = require ( 'passport' ) ,
4
- url = require ( 'url' ) ,
5
- GoogleStrategy = require ( 'passport-google-oauth' ) . OAuth2Strategy ,
6
- config = require ( '../config' ) ,
7
- users = require ( '../../app/controllers/users.server.controller' ) ;
4
+ url = require ( 'url' ) ,
5
+ GoogleStrategy = require ( 'passport-google-oauth' ) . OAuth2Strategy ,
6
+ config = require ( '../config' ) ,
7
+ users = require ( '../../app/controllers/users.server.controller' ) ;
8
8
9
9
module . exports = function ( ) {
10
- // Use google strategy
11
- passport . use ( new GoogleStrategy ( {
12
- clientID : config . google . clientID ,
13
- clientSecret : config . google . clientSecret ,
14
- callbackURL : config . google . callbackPath ,
15
- passReqToCallback : true
16
- } ,
17
- function ( req , accessToken , refreshToken , profile , done ) {
18
- // Set the provider data and include tokens
19
- var providerData = profile . _json ;
20
- providerData . accessToken = accessToken ;
21
- providerData . refreshToken = refreshToken ;
22
-
23
- // Create the user OAuth profile
24
- var providerUserProfile = {
25
- firstName : profile . name . givenName ,
26
- lastName : profile . name . familyName ,
27
- displayName : profile . displayName ,
28
- email : profile . emails [ 0 ] . value ,
29
- username : profile . username ,
30
- provider : 'google' ,
31
- providerIdentifierField : 'id' ,
32
- providerData : providerData
33
- } ;
10
+ // Use google strategy
11
+ passport . use ( new GoogleStrategy ( {
12
+ clientID : config . google . clientID ,
13
+ clientSecret : config . google . clientSecret ,
14
+ callbackURL : config . google . callbackPath ,
15
+ passReqToCallback : true
16
+ } ,
17
+ function ( req , accessToken , refreshToken , profile , done ) {
18
+ // Set the provider data and include tokens
19
+ var providerData = profile . _json ;
20
+ providerData . accessToken = accessToken ;
21
+ providerData . refreshToken = refreshToken ;
34
22
35
- // Save the user OAuth profile
36
- users . saveOAuthUserProfile ( req , providerUserProfile , done ) ;
37
- }
38
- ) ) ;
39
- } ;
23
+ // Create the user OAuth profile
24
+ var providerUserProfile = {
25
+ firstName : profile . name . givenName ,
26
+ lastName : profile . name . familyName ,
27
+ displayName : profile . displayName ,
28
+ email : profile . emails [ 0 ] . value ,
29
+ username : profile . username ,
30
+ provider : 'google' ,
31
+ providerIdentifierField : 'id' ,
32
+ providerData : providerData
33
+ } ;
34
+
35
+ // Save the user OAuth profile
36
+ users . saveOAuthUserProfile ( req , providerUserProfile , done ) ;
37
+ }
38
+ ) ) ;
39
+ } ;
0 commit comments