User ACP: redirect to Special:Login on own account deletion
authorDan
Fri, 21 Aug 2009 13:49:45 -0400
changeset 1089 16a1e8626dd9
parent 1088 3b25a59dacd1
child 1090 6c84fb196026
User ACP: redirect to Special:Login on own account deletion
includes/sessions.php
plugins/admin/UserManager.php
--- a/includes/sessions.php	Fri Aug 21 13:48:48 2009 -0400
+++ b/includes/sessions.php	Fri Aug 21 13:49:45 2009 -0400
@@ -835,7 +835,10 @@
           'success' => false,
           'error' => 'too_big_for_britches'
         );
+      
+      // grant session
       $sess = $this->register_session($row['user_id'], $username, ( isset($password_hmac) ? $password_hmac : $password ), $level, $remember);
+      
       if($sess)
       {
         if($level > USER_LEVEL_MEMBER)
--- a/plugins/admin/UserManager.php	Fri Aug 21 13:48:48 2009 -0400
+++ b/plugins/admin/UserManager.php	Fri Aug 21 13:49:45 2009 -0400
@@ -59,6 +59,24 @@
       if ( !$q )
         $db->_die();
       echo '<div class="info-box">' . $lang->get('acpum_msg_delete_success') . '</div>';
+      
+      // deleting own account?
+      if ( $user_id === $session->user_id )
+      {
+        // cute little hack to boot them out of the admin panel
+        echo '<script type="text/javascript">
+          addOnloadHook(function()
+          {
+            setTimeout(function()
+            {
+              eraseCookie("sid");
+              ENANO_SID = false;
+              auth_level = USER_LEVEL_MEMBER;
+              window.location = makeUrlNS("Special", "Login");
+            }, 3000);
+          });
+        </script>';
+      }
     }
     else
     {
@@ -264,7 +282,7 @@
       }
     }
     
-    if ( count($errors) > 0 || $avatar_post_fail )
+    if ( count($errors) > 0 || @$avatar_post_fail )
     {
       if ( count($errors) > 0 )
       {