Ejemplo n.º 1
0
 def onEdit(self, created):
     '''Triggered when a User is created or updated.'''
     login = self.login
     # Is it a local User or a LDAP User?
     isLocal = self.source == 'zodb'
     # Ensure correctness of some infos about this user.
     if isLocal:
         self.updateTitle()
         self.ensureAdminIsManager()
     if created:
         # Create the corresponding Zope user.
         from AccessControl.User import User as ZopeUser
         password = self.encryptPassword(self.password1)
         zopeUser = ZopeUser(login, password, self.roles, ())
         # Add it in acl_users if it is a local user.
         if isLocal:
             self.o.acl_users.data[login] = zopeUser
             # Add it in self.o._zopeUser if it is a LDAP user
         else:
             self.o._zopeUser = zopeUser
         # Remove our own password copies
         self.password1 = self.password2 = ''
     else:
         # Update the login itself if the user has changed it.
         oldLogin = self.o._oldLogin
         if oldLogin and (oldLogin != login):
             self.setLogin(oldLogin, login)
         del self.o._oldLogin
         # Update roles at the Zope level.
         zopeUser = self.getZopeUser()
         zopeUser.roles = self.roles
         # Update the password if the user has entered new ones.
         rq = self.request
         if rq.has_key('password1'):
             self.setPassword(rq['password1'])
             self.password1 = self.password2 = ''
     # "self" must be owned by its Zope user.
     if 'Owner' not in self.o.get_local_roles_for_userid(login):
         self.o.manage_addLocalRoles(login, ('Owner', ))
     # If the user was created by anon|system, anon|system can't stay Owner.
     for login in ('anon', 'system'):
         if login in self.o.__ac_local_roles__:
             del self.o.__ac_local_roles__[login]
     return self._callCustom('onEdit', created)
Ejemplo n.º 2
0
 def onEdit(self, created):
     '''Triggered when a User is created or updated.'''
     login = self.login
     # Is it a local User or a LDAP User?
     isLocal = self.source == 'zodb'
     # Ensure correctness of some infos about this user.
     if isLocal:
         self.updateTitle()
         self.ensureAdminIsManager()
     if created:
         # Create the corresponding Zope user.
         from AccessControl.User import User as ZopeUser
         password = self.encryptPassword(self.password1)
         zopeUser = ZopeUser(login, password, self.roles, ())
         # Add it in acl_users if it is a local user.
         if isLocal: self.o.acl_users.data[login] = zopeUser
         # Add it in self.o._zopeUser if it is a LDAP user
         else: self.o._zopeUser = zopeUser
         # Remove our own password copies
         self.password1 = self.password2 = ''
     else:
         # Update the login itself if the user has changed it.
         oldLogin = self.o._oldLogin
         if oldLogin and (oldLogin != login):
             self.setLogin(oldLogin, login)
         del self.o._oldLogin
         # Update roles at the Zope level.
         zopeUser = self.getZopeUser()
         zopeUser.roles = self.roles
         # Update the password if the user has entered new ones.
         rq = self.request
         if rq.has_key('password1'):
             self.setPassword(rq['password1'])
             self.password1 = self.password2 = ''
     # "self" must be owned by its Zope user.
     if 'Owner' not in self.o.get_local_roles_for_userid(login):
         self.o.manage_addLocalRoles(login, ('Owner',))
     # If the user was created by anon|system, anon|system can't stay Owner.
     for login in ('anon', 'system'):
         if login in self.o.__ac_local_roles__:
             del self.o.__ac_local_roles__[login]
     return self._callCustom('onEdit', created)
Ejemplo n.º 3
0
 def onEdit(self, created):
     '''Triggered when a User is created or updated'''
     login = self.login
     # Is it a local User or a LDAP User?
     isLocal = self.source == 'zodb'
     # Ensure correctness of some infos about this user
     if isLocal:
         self.updateTitle()
         self.ensureAdminIsManager()
     if created:
         # Create the corresponding Zope user
         from AccessControl.User import User as ZopeUser
         password = self.encryptPassword(self.password3)
         zopeUser = ZopeUser(login, password, self.roles, ())
         # Add it in acl_users if it is a local user.
         if isLocal: self.o.acl_users.data[login] = zopeUser
         # Add it in self.o._zopeUser if it is a LDAP or SSO user
         else: self.o._zopeUser = zopeUser
         # Remove our own password copies
         self.password3 = self.password4 = ''
     else:
         # Update the login itself if the user has changed it
         oldLogin = self.o._oldLogin
         if oldLogin and (oldLogin != login):
             self.setLogin(oldLogin, login)
         del self.o._oldLogin
         # Update roles at the Zope level
         zopeUser = self.getZopeUser()
         zopeUser.roles = self.roles
         # Update the password if the user has entered new ones
         rq = self.request
         if rq.get('page', 'main') == 'passwords':
             self.setPassword(rq['password1'])
             self.password1 = self.password2 = ''
     # "self" must be owned by its Zope user
     self.addLocalRole(login, 'Owner')
     # If the user was created by anon|system, anon|system can't stay Owner
     self.deleteLocalRole(('anon', 'system'))
     return self._callCustom('onEdit', created)