[gen] Bugfix while creating default users. Bugfix: do not perform LDAP authhentication when ldapConfig.enabled is False.

This commit is contained in:
Gaetan Delannay 2014-11-26 10:49:59 +01:00
parent 79ebc1cbf9
commit 5c41f1b3d2
2 changed files with 4 additions and 4 deletions

View file

@ -181,7 +181,7 @@ class ZopeInstaller:
for login, roles in self.defaultUsers.iteritems(): for login, roles in self.defaultUsers.iteritems():
if not appyTool.count('User', noSecurity=True, login=login): if not appyTool.count('User', noSecurity=True, login=login):
appyTool.create('users', noSecurity=True, id=login, login=login, appyTool.create('users', noSecurity=True, id=login, login=login,
password1=login, password2=login, password3=login, password4=login,
email='%s@appyframework.org'%login, roles=roles) email='%s@appyframework.org'%login, roles=roles)
appyTool.log('User "%s" created.' % login) appyTool.log('User "%s" created.' % login)

View file

@ -870,10 +870,10 @@ class ToolMixin(BaseMixin):
def getLdapUser(self, login, password): def getLdapUser(self, login, password):
'''Returns a local User instance corresponding to a LDAP user if p_login '''Returns a local User instance corresponding to a LDAP user if p_login
and p_password correspong to a valid LDAP user.''' and p_password correspong to a valid LDAP user.'''
# Check if LDAP is configured. # Check if LDAP is configured
cfg = self.getProductConfig(True).ldap cfg = self.getProductConfig(True).ldap
if not cfg: return if not cfg or not cfg.enabled: return
# Get a connector to the LDAP server and connect to the LDAP server. # Get a connector to the LDAP server and connect to the LDAP server
serverUri = cfg.getServerUri() serverUri = cfg.getServerUri()
connector = LdapConnector(serverUri, tool=self) connector = LdapConnector(serverUri, tool=self)
success, msg = connector.connect(cfg.adminLogin, cfg.adminPassword) success, msg = connector.connect(cfg.adminLogin, cfg.adminPassword)