Skip to content

Commit

Permalink
We can log in with Facebook & Twitter now. We're running for GitHub n…
Browse files Browse the repository at this point in the history
…ext\!
  • Loading branch information
abelmartin committed Sep 19, 2011
1 parent 8f0c81c commit 556e6a7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
9 changes: 9 additions & 0 deletions app.js
Expand Up @@ -7,6 +7,7 @@ var express = require('express'),
var usersById = {};
var nextUserId = 0;
var usersByTwitId = {};
var usersByFbId = {};

everyauth
.twitter
Expand All @@ -17,6 +18,14 @@ everyauth
})
.redirectPath('/');

everyauth.facebook
.appId(conf.fb.appId)
.appSecret(conf.fb.appSecret)
.findOrCreateUser( function (session, accessToken, accessTokExtra, fbUserMetadata) {
return usersByFbId[fbUserMetadata.id] || (usersByFbId[fbUserMetadata.id] = addUser('facebook', fbUserMetadata));
})
.redirectPath('/');

function addUser (source, sourceUser) {
var user;
if (arguments.length === 1) { // password-based
Expand Down
20 changes: 13 additions & 7 deletions views/layout.jade
Expand Up @@ -9,16 +9,22 @@ html
a#Home(href="/private") Private
- if(everyauth.loggedIn)
ul#Authed
li
Hi #{everyauth.twitter.user.name}!
li
img(src="#{everyauth.twitter.user.profile_image_url}")

// li= JSON.stringify(everyauth.twitter.user)
- if(everyauth.twitter)
li
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)
li
a(href="/logout") Sign Out
- else
ul#Authenticate
li
a(href="/auth/twitter") auth with twitter
a(href='/auth/twitter', style='border: 0px')
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

!= body

0 comments on commit 556e6a7

Please sign in to comment.