Introduced genericHanleRequestLoginAreaFailedRedirect()
authorRoland Haeder <roland@mxchange.org>
Tue, 7 Apr 2015 14:40:24 +0000 (16:40 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 7 Apr 2015 14:40:24 +0000 (16:40 +0200)
Signed-off-by: Roland H├Ąder <roland@mxchange.org>
inc/classes/main/controller/class_BaseController.php
inc/classes/main/controller/html/login/class_HtmlLoginAreaController.php

index d195c9e..db7521a 100644 (file)
@@ -130,6 +130,46 @@ class BaseController extends BaseFrameworkSystem implements Registerable {
                $responseInstance->flushBuffer();
        }
 
+       /**
+        * Generic execute of the command: pre and post filters with redirect
+        * but request becomes valid after pre-filters run.
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @param       $responseInstance       An instance of a response class
+        * @return      void
+        */
+       public function genericHanleRequestLoginAreaFailedRedirect (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get the command instance from the resolver by sending a request instance to the resolver
+               $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
+
+               // 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();
+               }
+
+               // This request was valid! :-D
+               $requestInstance->requestIsValid();
+
+               // Execute the command
+               $commandInstance->execute($requestInstance, $responseInstance);
+
+               // Run the pre filters
+               $this->executePostFilters($requestInstance, $responseInstance);
+
+               // Flush the response out
+               $responseInstance->flushBuffer();
+       }
+
        /**
         * Private method to initialize a given filter chain
         *
index 0c7725c..375bdee 100644 (file)
@@ -70,35 +70,11 @@ class HtmlLoginAreaController extends BaseController implements Controller {
         * @return      void
         */
        public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
-               // Get the command instance from the resolver by sending a request instance to the resolver
-               $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
-
-               // 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();
-               }
-
-               // This request was valid! :-D
-               $requestInstance->requestIsValid();
-
-               // Execute the command
-               $commandInstance->execute($requestInstance, $responseInstance);
-
-               // Run the pre filters
-               $this->executePostFilters($requestInstance, $responseInstance);
-
-               // Flush the response out
-               $responseInstance->flushBuffer();
+               /*
+                * Generic execute of the command: pre and post filters with redirect
+                * but request becomes valid after pre-filters run.
+                */
+               $this->genericHanleRequestLoginAreaFailedRedirect($requestInstance, $responseInstance);
        }
 }