UNPKG

@custonomy/passport-custonomy

Version:

Passport strategy for authenticating with Custonomy using OpenID 2.0. This module lets you authenticate using Custonomy in your Node.js applications. By plugging into Passport, Custonomy authentication can be easily and unobtrusively integrated into any a

43 lines (40 loc) 1.04 kB
/** * Parse profile. * * Parses user profiles as fetched from Custonomy API. * * The amount of detail in the profile varies based on the scopes granted by the * user. The following scope values add additional data: * * `profile` - basic profile information * `email` - email address * * * @param {object|string} json * @return {object} * @access public */ exports.parse = function(json) { if ('string' == typeof json) { json = JSON.parse(json); } var profile = {} , i, len; profile.id = json.id; profile.displayName = json.displayName; if (json.name) { profile.name = { familyName: json.name.familyName, givenName: json.name.givenName }; } if (json.emails) { profile.emails = []; for (i = 0, len = json.emails.length; i < len; ++i) { profile.emails.push({ value: json.emails[i].value, type: json.emails[i].type }) } } if (json.image) { profile.photos = [{ value: json.image.url }]; } profile.gender = json.gender; return profile; };