]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Redirect to https when making an http request for a sensitive action
authorCraig Andrews <candrews@integralblue.com>
Thu, 21 Oct 2010 00:22:34 +0000 (20:22 -0400)
committerCraig Andrews <candrews@integralblue.com>
Thu, 21 Oct 2010 00:26:35 +0000 (20:26 -0400)
actions/login.php
actions/register.php
index.php

index 07c601a4dba7aa70d6254e02713a5ab55f980cd2..103df7ee5ad59a53b51e69b3a72ee6fa9774c054 100644 (file)
@@ -62,28 +62,6 @@ class LoginAction extends Action
         return false;
     }
 
-    /**
-     * Prepare page to run
-     *
-     *
-     * @param $args
-     * @return string title
-     */
-
-    function prepare($args)
-    {
-        parent::prepare($args);
-
-        // @todo this check should really be in index.php for all sensitive actions
-        $ssl = common_config('site', 'ssl');
-        if (empty($_SERVER['HTTPS']) && ($ssl == 'always' || $ssl == 'sometimes')) {
-            common_redirect(common_local_url('login'));
-            // exit
-        }
-
-        return true;
-    }
-
     /**
      * Handle input, produce output
      *
index 7307bc689b26cda56839fbadfb4ada3992bbe14d..9b8161e0824dd0c2b872c54a6be5abd886345009 100644 (file)
@@ -74,13 +74,6 @@ class RegisterAction extends Action
         parent::prepare($args);
         $this->code = $this->trimmed('code');
 
-        // @todo this check should really be in index.php for all sensitive actions
-        $ssl = common_config('site', 'ssl');
-        if (empty($_SERVER['HTTPS']) && ($ssl == 'always' || $ssl == 'sometimes')) {
-            common_redirect(common_local_url('register'));
-            // exit
-        }
-
         if (empty($this->code)) {
             common_ensure_session();
             if (array_key_exists('invitecode', $_SESSION)) {
index 21e222e3b803c2d45e7dae07511b84eed66a0bf6..5a08aa07825c4d11b87a2e726c81c1db5be8b4ee 100644 (file)
--- a/index.php
+++ b/index.php
@@ -283,6 +283,14 @@ function main()
         return;
     }
 
+    $site_ssl = common_config('site', 'ssl');
+
+    // If the request is HTTP and it should be HTTPS...
+    if ($site_ssl != 'never' && !StatusNet::isHTTPS() && common_is_sensitive($args['action'])) {
+        common_redirect(common_local_url($args['action'], $args));
+        return;
+    }
+
     $args = array_merge($args, $_REQUEST);
 
     Event::handle('ArgsInitialize', array(&$args));