From: Vincent Zanotti Date: Sun, 28 Sep 2008 10:26:54 +0000 (+0200) Subject: Updates the GoogleApps password, if required, when an above-10-chars password was... X-Git-Tag: xorg/0.10.0~92 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=e0e27d631c07e67207c5e66d1ea58d167c920f36;p=platal.git 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 --- 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) {