Skip to content

Commit

Permalink
Merge pull request #7472 from RocketChat/always-set-ldap-property
Browse files Browse the repository at this point in the history
[FIX] Always set LDAP properties on login
  • Loading branch information
rodrigok committed Jul 14, 2017
1 parent 4974ca3 commit 9aba96e
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions packages/rocketchat-ldap/server/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ getDataToSyncUserData = function getDataToSyncUserData(ldapUser, user) {
const syncUserData = RocketChat.settings.get('LDAP_Sync_User_Data');
const syncUserDataFieldMap = RocketChat.settings.get('LDAP_Sync_User_Data_FieldMap').trim();

const userData = {};

if (syncUserData && syncUserDataFieldMap) {
const fieldMap = JSON.parse(syncUserDataFieldMap);
const userData = {};
const emailList = [];
_.map(fieldMap, function(userField, ldapField) {
switch (userField) {
Expand Down Expand Up @@ -125,21 +126,21 @@ getDataToSyncUserData = function getDataToSyncUserData(ldapUser, user) {
userData.emails = emailList;
}
}
}

const uniqueId = getLdapUserUniqueID(ldapUser);
const uniqueId = getLdapUserUniqueID(ldapUser);

if (uniqueId && (!user.services || !user.services.ldap || user.services.ldap.id !== uniqueId.value || user.services.ldap.idAttribute !== uniqueId.attribute)) {
userData['services.ldap.id'] = uniqueId.value;
userData['services.ldap.idAttribute'] = uniqueId.attribute;
}
if (uniqueId && (!user.services || !user.services.ldap || user.services.ldap.id !== uniqueId.value || user.services.ldap.idAttribute !== uniqueId.attribute)) {
userData['services.ldap.id'] = uniqueId.value;
userData['services.ldap.idAttribute'] = uniqueId.attribute;
}

if (user.ldap !== true) {
userData.ldap = true;
}
if (user.ldap !== true) {
userData.ldap = true;
}

if (_.size(userData)) {
return userData;
}
if (_.size(userData)) {
return userData;
}
};

Expand Down

0 comments on commit 9aba96e

Please sign in to comment.