Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add google login #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions app/helpers/passport/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var SUPPORTED_SERVICES = [
'twitter'
, 'facebook'
, 'yammer'
, 'google'
];

passport.use(new LocalStrategy(function(username, password, done) {
Expand Down Expand Up @@ -41,13 +42,19 @@ SUPPORTED_SERVICES.forEach(function (item) {
callbackURL: geddy.config.fullHostname + '/auth/' +
item + '/callback'
}
, Strategy = require('passport-' + item).Strategy;
, Strategy = require('passport-' + item).Strategy
, verifyCallback = function(token, tokenSecret, profile, done) {
done(null, profile);
};

geddy.mixin(config, geddy.config.passport[item]);
passport.use(new Strategy(config,
function(token, tokenSecret, profile, done) {
done(null, profile);
}));

if(item=='google'){
verifyCallback = function(identity, profile, done) {
done(null, profile);
};
}
passport.use(new Strategy(config, verifyCallback));
});

var actions = new (function () {
Expand Down
10 changes: 10 additions & 0 deletions app/helpers/passport/strategies.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,15 @@ module.exports = {
return userData;
}
}
, google: {
name: 'Google'
, keyField: 'id'
, parseProfile: function (profile) {
var userData = {
givenName: profile.name.givenName
, familyName: profile.name.familyName
};
return userData;
}
};

2 changes: 1 addition & 1 deletion app/views/ejs/main/index.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<h1>Hello, stranger</h1>
<p>You're not authenticated with this app.</p>
<p><%- linkTo('Click here to create a user account.', addUserPath) %></p>
<p><%- linkTo('Click here to log in with Facebook or Twitter.', loginPath) %></p>
<p><%- linkTo('Click here to log in with Facebook, Twitter or Google.', loginPath) %></p>
<% } %>
</div>
5 changes: 5 additions & 0 deletions app/views/ejs/main/login.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,10 @@
href="<%= geddy.config.fullHostname %><%= facebookPath %>">
Log in with Facebook
</a>
&nbsp;
<a class="btn-auth btn-google large"
href="<%= geddy.config.fullHostname %><%= googlePath %>">
Log in with Google
</a>
</p>
</div>
2 changes: 1 addition & 1 deletion app/views/handlebars/main/index.html.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
<h1>Hello, stranger</h1>
<p>You're not authenticated with this app.</p>
<p>{{{ linkTo 'Click here to create a user account.' addUserPath }}}</p>
<p>{{{ linkTo 'Click here to log in with Facebook or Twitter.' loginPath }}}</p>
<p>{{{ linkTo 'Click here to log in with Facebook, Twitter or Google.' loginPath }}}</p>
{{/if}}
</div>
5 changes: 5 additions & 0 deletions app/views/handlebars/main/login.html.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,10 @@
href="{{ geddy.config.fullHostname }}{{ facebookPath }}%>">
Log in with Facebook
</a>
&nbsp;
<a class="btn-auth btn-google large"
href="{{ geddy.config.fullHostname }}{{ googlePath }}%>">
Log in with Google
</a>
</p>
</div>
2 changes: 1 addition & 1 deletion app/views/jade/main/index.html.jade
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
p
!= linkTo('Click here to create a user account.', addUserPath)
p
!= linkTo('Click here to log in with Facebook or Twitter.', loginPath)
!= linkTo('Click here to log in with Facebook, Twitter or Google.', loginPath)
2 changes: 2 additions & 0 deletions app/views/jade/main/login.html.jade
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
a.btn-auth.btn-twitter.large(href="#{geddy.config.fullHostname}#{twitterPath}") Log in with Twitter
| &nbsp;
a.btn-auth.btn-facebook.large(href="#{geddy.config.fullHostname}#{facebookPath}") Log in with Facebook
| &nbsp;
a.btn-auth.btn-google.large(href="#{geddy.config.fullHostname}#{googlePath}") Log in with Google



Expand Down
2 changes: 1 addition & 1 deletion app/views/mustache/main/index.html.ms
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
<h1>Hello, stranger</h1>
<p>You're not authenticated with this app.</p>
<p>{{{ linkTo 'Click here to create a user account.' addUserPath }}}</p>
<p>{{{ linkTo 'Click here to log in with Facebook or Twitter.' loginPath }}}</p>
<p>{{{ linkTo 'Click here to log in with Facebook, Twitter or Google.' loginPath }}}</p>
{{/if}}
</div>
5 changes: 5 additions & 0 deletions app/views/mustache/main/login.html.ms
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,10 @@
href="{{ geddy.config.fullHostname }}{{ facebookPath }}%>">
Log in with Facebook
</a>
&nbsp;
<a class="btn-auth btn-google large"
href="{{ geddy.config.fullHostname }}{{ googlePath }}%>">
Log in with Google
</a>
</p>
</div>
2 changes: 2 additions & 0 deletions config/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ router.get('/auth/facebook').to('Auth.facebook');
router.get('/auth/facebook/callback').to('Auth.facebookCallback');
router.get('/auth/yammer').to('Auth.yammer');
router.get('/auth/yammer/callback').to('Auth.yammerCallback');
router.get('/auth/google').to('Auth.google');
router.get('/auth/google/callback').to('Auth.googleCallback');

// Basic routes
// router.match('/moving/pictures/:id', 'GET').to('Moving.pictures');
Expand Down
4 changes: 4 additions & 0 deletions config/secrets.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"yammer":{
"clientID": "XXXXX",
"clientSecret": "XXXXX"
},
"google": {
"returnURL": "XXXXX",
"realm": "XXXXX"
}
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"passport-twitter": "0.1.x",
"passport-facebook": "0.1.x",
"passport-yammer": "0.1.x",
"passport-google": "0.2.x",
"bcrypt": "0.7.x"
},
"main": "./lib/passport",
Expand Down