Browse files

Pass `profileFields` explicitly to `_convertProfileFields`

  • Loading branch information...
1 parent ba026ad commit d3eef8324e380c73a0341e157d7788c12996f801 @stevebest stevebest committed Jun 28, 2012
Showing with 5 additions and 5 deletions.
  1. +4 −4 lib/passport-facebook/strategy.js
  2. +1 −1 test/strategy-test.js
View
8 lib/passport-facebook/strategy.js
@@ -101,7 +101,7 @@ Strategy.prototype.authorizationParams = function (options) {
*/
Strategy.prototype.userProfile = function(accessToken, done) {
var self = this,
- fields = this._convertProfileFields();
+ fields = this._convertProfileFields(this.profileFields);
var url = 'https://graph.facebook.com/me'
+ (fields !== '' ? '?fields=' + fields : '');
@@ -148,7 +148,7 @@ Strategy.prototype._includeProfileField = function(field) {
|| this.profileFields.indexOf(field) !== -1;
}
-Strategy.prototype._convertProfileFields = function() {
+Strategy.prototype._convertProfileFields = function(profileFields) {
var fields = [];
var fieldsMap = {
'id': 'id',
@@ -160,10 +160,10 @@ Strategy.prototype._convertProfileFields = function() {
'emails': 'email',
'photos': 'picture'
};
- this.profileFields.forEach(function (f) {
+ profileFields.forEach(function (f) {
if (typeof fieldsMap[f] === 'undefined') return;
- if (typeof fieldsMap[f] === 'object') { // actually, array
+ if (Array.isArray(fieldsMap[f])) {
Array.prototype.push.apply(fields, fieldsMap[f]);
} else {
fields.push(fieldsMap[f]);
View
2 test/strategy-test.js
@@ -185,7 +185,7 @@ vows.describe('FacebookStrategy').addBatch({
'when converting field names to facebook api': {
topic: function(strategy) {
- this.callback(null, strategy._convertProfileFields());
+ this.callback(null, strategy._convertProfileFields(strategy.profileFields));
},
'should return a string of comma-separated field names': function(err, fields) {

0 comments on commit d3eef83

Please sign in to comment.