Skip to content

Instantly share code, notes, and snippets.

@lvivier
Last active December 20, 2015 17:09
Show Gist options
  • Save lvivier/6166735 to your computer and use it in GitHub Desktop.
Save lvivier/6166735 to your computer and use it in GitHub Desktop.
Return an avatar from a FirebaseSimpleLogin user object.
/**
* Only CommonJS is cool
*/
module.exports = avatar
/**
* Example:
* var avatar = require('avatar')
* var auth = new FirebaseSimpleLogin(db, function (err, user) {
* user.avatar = avatar(user)
* })
*/
function avatar (user) {
// TODO: gravatar from email for Persona and password
return (user.provider == 'facebook') ?
('http://graph.facebook.com/'+user.id+'/picture') :
user.profile_image_url ||
user.avatar_url
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment