]> git.mxchange.org Git - shipsimu.git/commitdiff
Auth filter basicly completed, user update filter added (stubs), minor fixes
authorRoland Häder <roland@mxchange.org>
Wed, 18 Jun 2008 21:29:17 +0000 (21:29 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 18 Jun 2008 21:29:17 +0000 (21:29 +0000)
.gitattributes
application/ship-simu/config.php
inc/classes/main/controller/login/class_WebLoginAreaController.php
inc/classes/main/filter/auth/class_UserAuthFilter.php
inc/classes/main/filter/update/.htaccess [new file with mode: 0644]
inc/classes/main/filter/update/class_UserUpdateFilter.php [new file with mode: 0644]
inc/classes/main/result/class_DatabaseResult.php

index 05dd822db032d20d45311109a412ff8818d64a47..0ff33d2818aa9f545a82d3b787adb528db4f381b 100644 (file)
@@ -394,6 +394,8 @@ inc/classes/main/filter/news/class_NewsDownloadFilter.php -text
 inc/classes/main/filter/news/class_NewsProcessFilter.php -text
 inc/classes/main/filter/null/.htaccess -text
 inc/classes/main/filter/null/class_NullFilter.php -text
+inc/classes/main/filter/update/.htaccess -text
+inc/classes/main/filter/update/class_UserUpdateFilter.php -text
 inc/classes/main/filter/validator/.htaccess -text
 inc/classes/main/filter/validator/class_EmailValidatorFilter.php -text
 inc/classes/main/filter/validator/class_PasswordValidatorFilter.php -text
index 0217b61309f08382b4db4a69d0eb16f3363163b6..9c000d85e6c209a47270b36156ad1592f4747866 100644 (file)
@@ -94,15 +94,18 @@ $cfg->setConfigEntry('login_default_action', "welcome");
 // CFG: NEWS-READER-CLASS
 $cfg->setConfigEntry('news_reader_class', "DefaultNewsReader");
 
-// CFG: NEWS-DOWNLOAD-FILTER
+// CFG: NEWS-DOWNLOAD-CLASS
 $cfg->setConfigEntry('news_download_class', "NewsDownloadFilter");
 
-// CFG: NEWS-PROCESS-FILTER
+// CFG: NEWS-PROCESS-CLASS
 $cfg->setConfigEntry('news_process_class', "NewsProcessFilter");
 
-// CFG: USER-AUTH-FILTER
+// CFG: USER-AUTH-CLASS
 $cfg->setConfigEntry('user_auth_class', "UserAuthFilter");
 
+// CFG: USER-UPDATE-CLASS
+$cfg->setConfigEntry('user_update_class', "UserUpdateFilter");
+
 // CFG: NEWS-HOME-LIMIT
 $cfg->setConfigEntry('news_home_limit', 10);
 
index 883cfca36653c216257a35dc1765fced7817ccfa..7ea4e50d5e77b21e01273de534e40aab913c0c8d 100644 (file)
@@ -51,11 +51,20 @@ class WebLoginAreaController extends BaseController implements Controller {
                // Set the command resolver
                $controllerInstance->setResolverInstance($resolverInstance);
 
-               // Add some filters to this controller
+               // User auth filter
                $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_class'));
+
+               // User update filter
+               $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_update_class'));
+
+               // News fetcher filter
                $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_class'));
+
+               // News proccess/display-preparation
                $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_class'));
 
+               /* @TODO: Add some filters to this controller */
+
                // Return the prepared instance
                return $controllerInstance;
        }
index 5754bf1d6643b6841d29a833b4e898d4999f947a..dac1ebc09205806a17c3b6baa386df245a2992d9 100644 (file)
@@ -78,6 +78,7 @@ class UserAuthFilter extends BaseFilter implements Filterable {
         * @param       $responseInstance       An instance of a class with an Responseable interface
         * @return      void
         * @throws      UserAuthorizationException      If the auth login was not found or if it was invalid
+        * @throws      UserPasswordMismatchException   If the supplied password hash does not match
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Then get an auth instance for checking and updating the auth cookies
@@ -103,10 +104,20 @@ class UserAuthFilter extends BaseFilter implements Filterable {
 
                        // Stop here
                        throw new UserAuthorizationException($this, self::EXCEPTION_AUTH_DATA_INVALID);
-               }
+               } // END - if
 
-               // Destroy safely the auth instance
-               unset($authInstance);
+               // Now, try to get a user instance
+               $userInstance = User::createUserByUserName($authLogin);
+
+               // Is the password correct?
+               if ($userInstance->getPasswordHash() !== $authHash) {
+                       // Mismatching password
+                       throw new UserPasswordMismatchException(array($this, $userInstance), User::EXCEPTION_USER_PASS_MISMATCH);
+               } // END - if
+
+               // Remember auth and user instances in registry
+               Registry::getRegistry()->addInstance('auth', $authInstance);
+               Registry::getRegistry()->addInstance('user', $userInstance);
        }
 }
 
diff --git a/inc/classes/main/filter/update/.htaccess b/inc/classes/main/filter/update/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/filter/update/class_UserUpdateFilter.php b/inc/classes/main/filter/update/class_UserUpdateFilter.php
new file mode 100644 (file)
index 0000000..b8f598f
--- /dev/null
@@ -0,0 +1,82 @@
+<?php
+/**
+ * A filter for updating the user account like last activity, last action
+ * performed and so on.
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class UserUpdateFilter extends BaseFrameworkSystem implements Filterable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("User update filter");
+
+               // Create unique ID number
+               $this->generateUniqueId();
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+
+       /**
+        * Creates an instance of this filter class
+        *
+        * @return      $filterInstance         An instance of this filter class
+        */
+       public final static function createUserUpdateFilter () {
+               // Get a new instance
+               $filterInstance = new UserUpdateFilter();
+
+               // Return the instance
+               return $filterInstance;
+       }
+
+       /**
+        * Executes the filter with given request and response objects
+        *
+        * @param       $requestInstance        An instance of a class with an Requestable interface
+        * @param       $responseInstance       An instance of a class with an Responseable interface
+        * @return      void
+        */
+       public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get user instance from registry
+               $userInstance = Registry::getRegistry()->getInstance('user');
+
+               // Now update last activity
+               $userInstance->updateLastActivity();
+
+               // Update auth data as well
+               /* @TODO Add more user updates here */
+
+               // Write all updates to the database
+               $userInstance->flushUpdates();
+       }
+}
+
+// [EOF]
+?>
index 017547259c44b709e34d0c3920e322c1ef76683d..fb02af3f1412e9f633c7da0ab028d3ca1cf8a725 100644 (file)
@@ -192,7 +192,7 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Se
         * @return      $result                         Found result entry
         */
        public function searchEntry (LocalSearchCriteria $criteriaInstance) {
-               die("OK");
+               die(__METHOD__.": OK");
        }
 }