Introduced genericHanleRequestLoginFailedRedirect().
authorRoland Haeder <roland@mxchange.org>
Mon, 6 Apr 2015 23:13:02 +0000 (01:13 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 6 Apr 2015 23:13:02 +0000 (01:13 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
inc/classes/main/controller/class_BaseController.php
inc/classes/main/controller/html/form/class_HtmlDoFormController.php

index 3b0d24c18cd3f878fdd0880b07bc4448fcea3209..d195c9e76bd21972997495f7a2b5f7a39562dc23 100644 (file)
@@ -84,6 +84,52 @@ class BaseController extends BaseFrameworkSystem implements Registerable {
                $responseInstance->flushBuffer();
        }
 
                $responseInstance->flushBuffer();
        }
 
+       /**
+        * Handles the given request and response, redirects to login_failed if
+        * UserAuthorizationException is thrown.
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @param       $responseInstance       An instance of a response class
+        * @return      void
+        */
+       public function genericHanleRequestLoginFailedRedirect (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get the "form action"
+               $formAction = $requestInstance->getRequestElement('form');
+
+               // Get command instance from resolver
+               $commandInstance = $this->getResolverInstance()->resolveCommand($formAction);
+
+               // Add more filters by the command
+               $commandInstance->addExtraFilters($this, $requestInstance);
+
+               // Try to run the pre filters, if auth exceptions come through redirect here
+               try {
+                       // Run the pre filters
+                       $this->executePreFilters($requestInstance, $responseInstance);
+               } catch (UserAuthorizationException $e) {
+                       // Redirect to main page
+                       $responseInstance->redirectToConfiguredUrl('login_failed');
+
+                       // Exit here
+                       exit();
+               }
+
+               /*
+                * Is the request still valid? Post filters shall only be executed of
+                * the request is valid
+                */
+               if ($requestInstance->isRequestValid()) {
+                       // Execute the command
+                       $commandInstance->execute($requestInstance, $responseInstance);
+
+                       // Execute *very* generic ppost filters
+                       $this->executePostFilters($requestInstance, $responseInstance);
+               } // END - if
+
+               // Flush the buffer out
+               $responseInstance->flushBuffer();
+       }
+
        /**
         * Private method to initialize a given filter chain
         *
        /**
         * Private method to initialize a given filter chain
         *
index 38ae3c2a7b9405624e01ac12db54c640359f2fa3..2dc6b884f31b48b1429e8167886750f2a1e98494 100644 (file)
@@ -60,39 +60,8 @@ class HtmlDoFormController extends BaseController implements Controller {
         * @return      void
         */
        public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
         * @return      void
         */
        public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
-               // Get the "form action"
-               $formAction = $requestInstance->getRequestElement('form');
-
-               // Get command instance from resolver
-               $commandInstance = $this->getResolverInstance()->resolveCommand($formAction);
-
-               // Add more filters by the command
-               $commandInstance->addExtraFilters($this, $requestInstance);
-
-               // Try to run the pre filters, if auth exceptions come through redirect here
-               try {
-                       // Run the pre filters
-                       $this->executePreFilters($requestInstance, $responseInstance);
-               } catch (UserAuthorizationException $e) {
-                       // Redirect to main page
-                       $responseInstance->redirectToConfiguredUrl('login_failed');
-
-                       // Exit here
-                       exit();
-               }
-
-               // Is the request still valid? Post filters shall only be executed of
-               // the request is valid
-               if ($requestInstance->isRequestValid()) {
-                       // Execute the command
-                       $commandInstance->execute($requestInstance, $responseInstance);
-
-                       // Execute *very* generic ppost filters
-                       $this->executePostFilters($requestInstance, $responseInstance);
-               }
-
-               // Flush the buffer out
-               $responseInstance->flushBuffer();
+               // Generic handling with redirect to 'login_failed'
+               $this->genericHanleRequestLoginFailedRedirect($requestInstance, $responseInstance);
        }
 }
 
        }
 }