Skip to content

Commit

Permalink
uncomment lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Megapixel99 committed Aug 5, 2020
1 parent 7ecc875 commit 63cb280
Showing 1 changed file with 46 additions and 46 deletions.
92 changes: 46 additions & 46 deletions lib/passport-cas.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,52 +221,52 @@ CasStrategy.prototype.authenticate = function (req, options) {
emails: [],
};

// Map relevant extended attributes returned by CAS into the profile
// for (var key in profile) {
// if (key == 'name') {
// for (const subKey in profile[key]) {
// var mappedKey = self.casPropertyMap[subKey] || subKey;
// var value = attributes[mappedKey];
// if (Array.isArray(value)) {
// profile.name[subKey] = value[0];
// } else {
// profile.name[subKey] = value;
// }
// delete attributes[mappedKey];
// }
// } else if (key == 'emails') {
// var mappedKey = self.casPropertyMap.emails || 'emails';
// const emails = attributes[mappedKey];
// if (Array.isArray(emails)) {
// if (typeof emails[0] === 'object') {
// profile.emails = emails;
// } else {
// for (let i = 0; i < emails.length; i++) {
// profile.emails.push({
// value: emails[i],
// type: 'default',
// });
// }
// }
// } else {
// profile.emails = [emails];
// }
// delete attributes[mappedKey];
// } else {
// var mappedKey = self.casPropertyMap[key] || key;
// var value = attributes[mappedKey];
// if (Array.isArray(value)) {
// profile[key] = value[0];
// } else if (value) {
// profile[key] = value;
// }
// delete attributes[mappedKey];
// }
// }
// // Add remaining attributes to the profile object
// for (var key in attributes) {
// profile[key] = attributes[key];
// }
Map relevant extended attributes returned by CAS into the profile
for (var key in profile) {
if (key == 'name') {
for (const subKey in profile[key]) {
var mappedKey = self.casPropertyMap[subKey] || subKey;
var value = attributes[mappedKey];
if (Array.isArray(value)) {
profile.name[subKey] = value[0];
} else {
profile.name[subKey] = value;
}
delete attributes[mappedKey];
}
} else if (key == 'emails') {
var mappedKey = self.casPropertyMap.emails || 'emails';
const emails = attributes[mappedKey];
if (Array.isArray(emails)) {
if (typeof emails[0] === 'object') {
profile.emails = emails;
} else {
for (let i = 0; i < emails.length; i++) {
profile.emails.push({
value: emails[i],
type: 'default',
});
}
}
} else {
profile.emails = [emails];
}
delete attributes[mappedKey];
} else {
var mappedKey = self.casPropertyMap[key] || key;
var value = attributes[mappedKey];
if (Array.isArray(value)) {
profile[key] = value[0];
} else if (value) {
profile[key] = value;
}
delete attributes[mappedKey];
}
}
// Add remaining attributes to the profile object
for (var key in attributes) {
profile[key] = attributes[key];
}

if (self._passReqToCallback) {
self._verify(req, username, profile, verified);
Expand Down

0 comments on commit 63cb280

Please sign in to comment.