Commits

Zhang Huangbin committed 1d55a12

Fixed: cannot update user password in pgsql backend.

Comments (0)

Files changed (2)

 = 0.1.8 =
-    * Fix missing tab 'Password' in LDAP user profile page.
+    * Fixed:
+        + Cannot update user password in pgsql backend.
 
 = 0.1.7 =
-    * Based on iRedAdmin-Pro-LDAP-1.6.4, iRedAdmin-Pro-MySQL-1.3.2,
+    * Based on iRedAdmin-Pro-LDAP-1.7.0, iRedAdmin-Pro-MySQL-1.4.0,
       iRedAdmin-Pro-PGSQL-1.0.
 
 = 0.1.6 =

libs/pgsql/user.py

 cfg = web.iredconfig
 session = web.config.get('_session', {})
 
-if session.get('enablePolicyd'):
-    from libs.policyd import throttle
-
 ENABLED_SERVICES = [
     'enablesmtp', 'enablesmtpsecured',
     'enablepop3', 'enablepop3secured',
             employeeNumber = data.get('employeeNumber', '')
             updates['employeeid'] = employeeNumber
 
+        elif self.profile_type == 'password':
+            newpw = str(data.get('newpw', ''))
+            confirmpw = str(data.get('confirmpw', ''))
+
+            # Verify new passwords.
+            qr = iredutils.verifyNewPasswords(newpw, confirmpw)
+            if qr[0] is True:
+                if 'storePasswordInPlainText' in data and settings.STORE_PASSWORD_IN_PLAIN:
+                    passwd = iredutils.getSQLPassword(qr[1], pwscheme='PLAIN')
+                else:
+                    passwd = iredutils.getSQLPassword(qr[1])
+            else:
+                return qr
+
+            # Hash/encrypt new password.
+            updates['password'] = passwd
+
+            # Update password last change date in column: passwordlastchange.
+            #
+            # Old iRedMail version doesn't have column mailbox.passwordlastchange,
+            # so we update it with a seperate SQL command with exception handle.
+            try:
+                self.conn.update(
+                    'mailbox',
+                    vars={'username': self.mail, },
+                    where='username=$username',
+                    passwordlastchange=iredutils.getGMTTime(),
+                )
+            except:
+                pass
+
         else:
             return (True,)