Skip to content

Instantly share code, notes, and snippets.

View bnoguchi's full-sized avatar

Brian Noguchi bnoguchi

View GitHub Profile
// This code doesn't accept a URL of /auth/twitter or /auth/github
var express = require('express')
, routes = require('./routes')
, util = require('util')
, everyauth = require('everyauth');
var app = module.exports = express.createServer();
@bnoguchi
bnoguchi / example.coffee
Created March 11, 2012 20:42
EveryAuth issue #208 (CoffeeScript)
bootstrapAuthentication()
application = express.createServer()
application.configure ->
bootstrap(application)
application.listen(2536)
bootstrapAuthentication = () ->
everyauth.twitter
@bnoguchi
bnoguchi / gist:1154982
Created August 18, 2011 19:46
findOrCreateUser
findOrCreateUser: function (sess, accessTok, accessTokExtra, fbUser) {
var promise = this.Promise()
, User = this.User()();
if(sess.auth == null || sess.auth.userId == null) {
User.findOne({'fb.id': fbUser.id}, function (err, foundUser) {
if (foundUser) {
if( foundUser.confirmed ) {
return promise.fulfill(foundUser);
} else {
assignFbDataToUser(foundUser, accessTok, accessTokExtra, fbUser);