       try person.updateFromTwitter twitter catch e then callback(e)
       person.save (err) -> callback(err, person)
 
+PersonSchema.static 'findOrCreateFromFacebook', (facebook, callback) ->
+  console.log arguments.magenta
+  Person.findOne
+    $or: [
+      { facebook_name: facebook.alias }
+      { 'fb.id': facebook.id }]
+    (error, person) ->
+      return callback(error) if error
+      person ||= new Person
+      try person.updateFromFacebook facebook catch e then callback(e)
+      person.save (err) -> callback(err, person)
+
 Person = mongoose.model 'Person', PersonSchema
 Person.ROLES = ROLES

      myHostname: env.hostname
      appId: env.facebook_app_id
      appSecret: env.secrets.facebook

ROLES.forEach (t) ->
  PersonSchema.virtual(t).get -> @role == t

_ = require 'underscore'
colors = require 'colors'
mongoose = require 'mongoose'
auth = require 'mongoose-auth'
env = require '../config/env'
