From e0e27d631c07e67207c5e66d1ea58d167c920f36 Mon Sep 17 00:00:00 2001 From: Vincent Zanotti Date: Sun, 28 Sep 2008 12:26:54 +0200 Subject: [PATCH] Updates the GoogleApps password, if required, when an above-10-chars password was successfuly detected and stored in the database. Follow-up to 2b18a8ff and 79afc233. Signed-off-by: Vincent Zanotti --- classes/xorgsession.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/classes/xorgsession.php b/classes/xorgsession.php index 05c2207..ffffbf7 100644 --- a/classes/xorgsession.php +++ b/classes/xorgsession.php @@ -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) { -- 2.1.4