Updates the GoogleApps password, if required, when an above-10-chars password was...
authorVincent Zanotti <vincent.zanotti@polytechnique.org>
Sun, 28 Sep 2008 10:26:54 +0000 (12:26 +0200)
committerVincent Zanotti <vincent.zanotti@polytechnique.org>
Sun, 28 Sep 2008 10:26:54 +0000 (12:26 +0200)
Follow-up to 2b18a8ff and 79afc233.

Signed-off-by: Vincent Zanotti <vincent.zanotti@polytechnique.org>
classes/xorgsession.php

index 05c2207..ffffbf7 100644 (file)
@@ -84,11 +84,20 @@ class XorgSession extends PlSession
                 $new_password = hash_xor(Env::v('xorpass'), $password);
                 $expected_response = hash_encrypt("$uname:$new_password:" . S::v('challenge'));
                 if ($response == $expected_response) {
-                      XDB::execute('UPDATE  auth_user_md5
-                                       SET  password = {?}
-                                     WHERE  user_id = {?}',
-                                   $new_password, $uid);
-                      /* TODO: update GApps password here!!! */
+                    XDB::execute('UPDATE  auth_user_md5
+                                     SET  password = {?}
+                                   WHERE  user_id = {?}',
+                                 $new_password, $uid);
+
+                    // Update the GoogleApps password as well, if required.
+                    global $globals;
+                    if ($globals->mailstorage->googleapps_domain) {
+                        require_once 'googleapps.inc.php';
+                        $account = new GoogleAppsAccount($uid);
+                        if ($account->active() && $account->sync_password) {
+                            $account->set_password($new_password);
+                        }
+                    }
                 }
             }
             if ($response != $expected_response) {