mirror of
https://github.com/hanzoai/passport-github.git
synced 2026-09-23 23:48:07 +00:00
27 lines
560 B
JavaScript
27 lines
560 B
JavaScript
/**
|
|
* Parse profile.
|
|
*
|
|
* @param {Object|String} json
|
|
* @return {Object}
|
|
* @api private
|
|
*/
|
|
exports.parse = function(json) {
|
|
if ('string' == typeof json) {
|
|
json = JSON.parse(json);
|
|
}
|
|
|
|
var profile = {};
|
|
profile.id = String(json.id);
|
|
profile.nodeId = json.node_id;
|
|
profile.displayName = json.name;
|
|
profile.username = json.login;
|
|
profile.profileUrl = json.html_url;
|
|
if (json.email) {
|
|
profile.emails = [{ value: json.email }];
|
|
}
|
|
if (json.avatar_url) {
|
|
profile.photos = [{ value: json.avatar_url }];
|
|
}
|
|
return profile;
|
|
};
|