1. Zhang Huangbin
  2. iredadmin-ose

Commits

Zhang Huangbin  committed a63af0c

Fix incorrect decorator for creating new user.

  • Participants
  • Parent commits 1dae8db
  • Branches default

Comments (0)

Files changed (3)

File controllers/ldap/user.py

View file
  • Ignore whitespace
         self.domain = web.safestr(i.get('domainName'))
         self.username = web.safestr(i.get('username'))
 
-        result = userLib.add(data=i)
+        result = userLib.add(domain=self.domain, data=i)
         if result[0] is True:
             web.seeother('/profile/user/general/%s?msg=SUCCESS' % (self.username + '@' + self.domain))
         else:

File libs/ldaplib/user.py

View file
  • Ignore whitespace
             return (False, ldaputils.getExceptionDesc(e))
 
 
-    @LDAPDecorators.check_global_admin
-    def add(self, data):
+    @LDAPDecorators.check_domain_access
+    def add(self, domain, data):
         # Get domain name, username, cn.
         self.domain = web.safestr(data.get('domainName')).lower()
         self.username = web.safestr(data.get('username')).lower()
             # Get telephoneNumber.
             employeeNumber = data.get('employeeNumber', 'None')
             mod_attrs += ldaputils.getSingleModAttr(attr='employeeNumber', value=employeeNumber, default='None')
-            
-            # TODO add multiple value support
+
             telephoneNumber = data.get('telephoneNumber', [])
             if telephoneNumber != [] and telephoneNumber != [u''] and telephoneNumber != []:
                 mod_attrs += [ (ldap.MOD_REPLACE, 'telephoneNumber', None) ]
             self.newpw = str(data.get('newpw', None))
             self.confirmpw = str(data.get('confirmpw', None))
              
-            self.result = iredutils.getNewPassword(newpw=self.newpw, confirmpw=self.confirmpw,)
-            if self.result[0] is True:
-                self.passwd = ldaputils.generatePasswd(self.result[1], pwscheme=cfg.general.get('default_pw_scheme', 'SSHA'))
+            result = iredutils.getNewPassword(newpw=self.newpw, confirmpw=self.confirmpw,)
+            if result[0] is True:
+                self.passwd = ldaputils.generatePasswd(result[1], pwscheme=cfg.general.get('default_pw_scheme', 'SSHA'))
                 mod_attrs += [ (ldap.MOD_REPLACE, 'userPassword', self.passwd) ]
             else:
-                return self.result
+                return result
 
         try:
             dn = ldaputils.convEmailToUserDN(self.mail)

File templates/default/ldap/user_create.html

View file
  • Ignore whitespace
 </div>
 {% endif %}
 
-{# Display input field for adding new domain. #}
+{# Display input field for adding new user. #}
 <div class="main-frm">
     <form class="frm-form" method="post" action="{{ctx.homepath}}/create/user">