X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fgoogleapps.php;h=d22f9b2cb0a3706fe935ac7ad125ecd5ee491b66;hb=6dae45b393a59fd04713b9c651ff0970aeec84d7;hp=f02053b3a3dbc42a8efd9da4173293564c650623;hpb=fcef7ce234a4d8ab53d923e4df740d75b359aced;p=platal.git diff --git a/modules/googleapps.php b/modules/googleapps.php index f02053b..d22f9b2 100644 --- a/modules/googleapps.php +++ b/modules/googleapps.php @@ -52,10 +52,10 @@ class GoogleAppsModule extends PLModule if ($account->active()) { $redirect = new Redirect(S::v('uid')); - $page->assign('redirect_unique', !$redirect->other_active(NULL)); + $page->assign('redirect_unique', !$redirect->other_active('googleapps')); - $storage = new MailStorageGoogleApps(S::v('uid')); - $page->assign('redirect_active', $storage->active()); + $storage = new EmailStorage(S::v('uid'), 'googleapps'); + $page->assign('redirect_active', $storage->active); } // Updates the Google Apps account as required. @@ -64,20 +64,22 @@ class GoogleAppsModule extends PLModule if ($subaction == 'sync') { $account->set_password_sync(true); $account->set_password(S::v('password')); - $page->trig("Ton mot de passe Google Apps sera dorénavant synchronisé avec ton mot de passe Polytechnique.org."); + pl_redirect('googleapps#password'); } else if ($subaction == 'nosync') { $account->set_password_sync(false); } else if (Post::has('response2') && !$account->sync_password) { + S::assert_xsrf_token(); $account->set_password(Post::v('response2')); } } if ($action == 'suspend' && Post::has('suspend') && $account->active()) { + S::assert_xsrf_token(); + if ($account->pending_update_suspension) { $page->trig("Ton compte est déjà en cours de désactivation."); } else { - $storage = new MailStorageGoogleApps(S::v('uid')); - if ($storage->disable()) { + if ($redirect->modify_one_email('googleapps', false) == SUCCESS) { $account->suspend(); $page->trig("Ton compte Google Apps est dorénavant désactivé."); } else { @@ -94,6 +96,8 @@ class GoogleAppsModule extends PLModule $page->assign('password_sync', Get::b('password_sync', true)); } if ($action == 'create' && Post::has('password_sync') && Post::has('redirect_mails')) { + S::assert_xsrf_token(); + $password_sync = Post::b('password_sync'); $redirect_mails = Post::b('redirect_mails'); if ($password_sync) { @@ -192,7 +196,7 @@ class GoogleAppsModule extends PLModule if ($user) { $account = new GoogleAppsAccount($user); - $storage = new MailStorageGoogleApps($user); + $storage = new EmailStorage($user, 'googleapps'); // Force synchronization of plat/al and Google Apps passwords. if ($action == 'forcesync' && $account->sync_password) { @@ -204,7 +208,7 @@ class GoogleAppsModule extends PLModule // Displays basic account information. $page->assign('account', $account); $page->assign('admin_account', GoogleAppsAccount::is_administrator($user)); - $page->assign('googleapps_storage', $storage->active()); + $page->assign('googleapps_storage', $storage->active); $page->assign('user', $user); // Retrieves user's pending requests.