Copyright updated, menu class added for 'home'
[shipsimu.git] / application / ship-simu / main / login / class_ShipSimuUserLogin.php
index eced73d98f53ec54eb18aed803084eb5ec4fff30..270a8c690b7c1986a082a8b2d96ce44be9339905 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, this is free software
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Ship-Simu Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -36,12 +36,6 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser {
                // Call parent constructor
                parent::__construct(__CLASS__);
 
-               // Set part description
-               $this->setObjectDescription("Login for Ship-Simu");
-
-               // Create unique ID number
-               $this->generateUniqueId();
-
                // Clean up a little
                $this->removeNumberFormaters();
                $this->removeSystemArray();
@@ -79,24 +73,19 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser {
                $method = null;
                $data = "";
 
-               // Get a instance of the registry
-               $userInstance = Registry::getRegistry()->getInstance('user');
+               // Get member class
+               $userClass = $this->getConfigInstance()->readConfig('user_class');
 
-               // Is there an instance?
-               if (is_null($userInstance)) {
-                       // Get member class
-                       $userClass = $this->getConfigInstance()->readConfig('user_class');
+               // Get a user instance
+               $userInstance = call_user_func_array(array($userClass, 'createMemberByRequest'), array($requestInstance));
 
-                       // Get a user instance
-                       $userInstance = call_user_func_array(array($userClass, 'createMemberByRequest'), array($requestInstance));
-
-                       // Remember this new instance in registry
-                       Registry::getRegistry()->addInstance($userInstance);
-               } // END - if
+               // Remember this new instance in registry
+               Registry::getRegistry()->addInstance('user', $userInstance);
 
                // Is the password correct?
-               if (!$userInstance->ifPasswordHashMatches($requestInstance)) {
+               if ($userInstance->ifPasswordHashMatches($requestInstance) === false) {
                        // Mismatching password
+                       $userInstance->debugInstance();
                        throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH);
                } // END - if
 
@@ -112,7 +101,7 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser {
        }
 
        /**
-        * Determines wether the login was fine. This is done by checking if the 'login' instance is in registry
+        * Determines wether the login was fine. This is done by checking if 'login' instance is in registry
         *
         * @return      $loginDone      Wether the login was fine or not
         */
@@ -125,14 +114,14 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser {
        }
 
        /**
-        * Encrypt the given request key or throw an exception if the key was not
-        * found in the request
+        * Encrypt given request key or throw an exception if key was not found in
+        * request
         *
         * @param       $requestKey             Key in request class
         * @return      void
         */
        public function encryptPassword ($requestKey) {
-               // Check if the password is found in the request
+               // Check if password is found in request
                if ($this->getRequestInstance()->isRequestElementSet($requestKey)) {
                        // So encrypt the password and store it for later usage in
                        // the request:
@@ -146,7 +135,7 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser {
                        // Get a crypto helper and hash the password
                        $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($plainPassword, $userInstance->getPasswordHash());
 
-                       // Store the hash back in the request
+                       // Store the hash back in request
                        $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword);
                } // END - if
        }