Added profile image on onlineList

This commit is contained in:
Wu Cheng-Han 2015-07-04 22:19:09 +08:00
parent 01685c255f
commit 85c67212ad
3 changed files with 24 additions and 9 deletions

View file

@ -348,6 +348,7 @@ function buildUserOutData(user) {
id: user.id,
login: user.login,
userid: user.userid,
photo: user.photo,
color: user.color,
cursor: user.cursor,
name: user.name,
@ -361,24 +362,23 @@ function updateUserData(socket, user) {
//retrieve user data from passport
if (socket.request.user && socket.request.user.logged_in) {
var profile = JSON.parse(socket.request.user.profile);
/*
var photo = null;
switch(profile.provider) {
case "facebook":
console.log(profile);
photo = 'https://graph.facebook.com/' + profile.id + '/picture';
break;
case "twitter":
photo = profile.photos[0];
photo = profile.photos[0].value;
break;
case "github":
photo = profile.avatar_url;
photo = 'https://avatars.githubusercontent.com/u/' + profile.id + '?s=48';
break;
case "dropbox":
//not image api provided
//no image api provided, use gravatar
photo = 'https://www.gravatar.com/avatar/' + md5(profile.emails[0].value);
break;
}
user.photo = photo;
*/
user.name = profile.displayName || profile.username;
user.userid = socket.request.user._id;
user.login = true;