Permalink
Browse files

GitHub auth works now. Huzzah\!

  • Loading branch information...
1 parent 556e6a7 commit 9f904f45d8218652ba358235903f897b599e6dd1 @abelmartin committed Sep 19, 2011
Showing with 18 additions and 1 deletion.
  1. +9 −0 app.js
  2. +9 −1 views/layout.jade
View
9 app.js
@@ -8,6 +8,7 @@ var usersById = {};
var nextUserId = 0;
var usersByTwitId = {};
var usersByFbId = {};
+var usersByGhId = {};
everyauth
.twitter
@@ -26,6 +27,14 @@ everyauth.facebook
})
.redirectPath('/');
+everyauth.github
+ .appId(conf.github.appId)
+ .appSecret(conf.github.appSecret)
+ .findOrCreateUser( function (sess, accessToken, accessTokenExtra, ghUser) {
+ return usersByGhId[ghUser.id] || (usersByGhId[ghUser.id] = addUser('github', ghUser));
+ })
+ .redirectPath('/');
+
function addUser (source, sourceUser) {
var user;
if (arguments.length === 1) { // password-based
View
@@ -14,9 +14,15 @@ html
Hi #{everyauth.twitter.user.name} from Twitter!
li
img(src="#{everyauth.twitter.user.profile_image_url}")
+
- if(everyauth.facebook)
li Hi #{everyauth.facebook.user.name} from Facebook!
- li= JSON.stringify(everyauth)
+
+ - if(everyauth.github)
+ li Hi #{everyauth.github.user.name} from GitHub!
+ li
+ img(src="https://secure.gravatar.com/avatar/#{everyauth.github.user.gravatar_id}")
+ // li= JSON.stringify(everyauth)
li
a(href="/logout") Sign Out
- else
@@ -26,5 +32,7 @@ html
img(style='border: 0px', src='https://si0.twimg.com/images/dev/buttons/sign-in-with-twitter-l.png')
li
a(href='auth/facebook') Sign in with Facebook
+ li
+ a(href='auth/github') Sign in with GitHub
!= body

0 comments on commit 9f904f4

Please sign in to comment.