Skip to content

Commit

Permalink
[FIX] LDAP login error on Enterprise version (#17497)
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-lehnen-rc authored Apr 30, 2020
1 parent e0b8676 commit 2808ce7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/ldap/server/loginHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ Accounts.registerLoginHandler('ldap', function(loginRequest) {
if (settings.get('LDAP_Login_Fallback') === true && typeof loginRequest.ldapPass === 'string' && loginRequest.ldapPass.trim() !== '') {
Accounts.setPassword(user._id, loginRequest.ldapPass, { logout: false });
}
logger.info('running afterLDAPLogin');
callbacks.run('afterLDAPLogin', { user, ldapUser, ldap });
return {
userId: user._id,
Expand Down
2 changes: 2 additions & 0 deletions app/ldap/server/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export function mapLdapGroupsToUserRoles(ldap, ldapUser, user) {
const syncUserRolesFieldMap = settings.get('LDAP_Sync_User_Data_GroupsMap').trim();

if (!syncUserRoles || !syncUserRolesFieldMap) {
logger.debug('not syncing user roles');
return [];
}

Expand Down Expand Up @@ -296,6 +297,7 @@ export function mapLDAPGroupsToChannels(ldap, ldapUser, user) {

const userChannels = [];
if (!syncUserRoles || !syncUserRolesAutoChannels || !syncUserRolesChannelFieldMap) {
logger.debug('not syncing groups to channels');
return [];
}

Expand Down
2 changes: 1 addition & 1 deletion ee/app/ldap-enterprise/server/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export const onLdapLogin = ({ user, ldapUser, ldap }) => {
const validateLdapRolesForEachLogin = settings.get('LDAP_Validate_Roles_For_Each_Login');
const userExists = user._id;
const userId = userExists ? user._id : user.userId;
const ldapUserRoles = getLdapRolesByUsername(ldapUser.uid, ldap);
if (!userExists || validateLdapRolesForEachLogin) {
const ldapUserRoles = getLdapRolesByUsername(ldapUser.uid, ldap);
const roles = getRocketChatRolesByLdapRoles(JSON.parse(settings.get('LDAP_Roles_To_Rocket_Chat_Roles')), ldapUserRoles);
updateUserUsingMappedLdapRoles(userId, roles);
}
Expand Down

0 comments on commit 2808ce7

Please sign in to comment.