X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=blobdiff_plain;f=application%2Fship-simu%2Fmain%2Flogin%2Fclass_ShipSimuGuestLogin.php;h=a026284d88abba64112ac18553915079f57d2dad;hp=f57cdee986b39e585c799a1f98014879aef6e35e;hb=0f10df895de1dd67a2bbec5264f01c5e146de952;hpb=d527a312ec4b2983fc0ecda2179ce335c1a5a1f9 diff --git a/application/ship-simu/main/login/class_ShipSimuGuestLogin.php b/application/ship-simu/main/login/class_ShipSimuGuestLogin.php index f57cdee..a026284 100644 --- a/application/ship-simu/main/login/class_ShipSimuGuestLogin.php +++ b/application/ship-simu/main/login/class_ShipSimuGuestLogin.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @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 ShipSimuGuestLogin extends BaseFrameworkSystem implements LoginableUser { // Call parent constructor parent::__construct(__CLASS__); - // Set part description - $this->setObjectDescription("Guest login for Ship-Simu"); - - // Create unique ID number - $this->generateUniqueId(); - // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); @@ -83,35 +77,29 @@ class ShipSimuGuestLogin extends BaseFrameworkSystem implements LoginableUser { // Detect login method (username or email) and try to get a userinstance if (!is_null($requestInstance->getRequestElement('user'))) { // Username found! - $method = "createGuestByUsername"; + $method = 'createGuestByUsername'; $data = $requestInstance->getRequestElement('user'); - } + } // END - if // Is a method detected? if (is_null($method)) { // Then abort here throw new UserAuthMethodException($this, self::EXCEPTION_MISSING_METHOD); - } elseif (!method_exists($this->getConfigInstance()->readConfig('guest_class'), $method)) { + } elseif (!method_exists($this->getConfigInstance()->getConfigEntry('guest_class'), $method)) { // The method is invalid! throw new MissingMethodException(array($this, $method), self::EXCEPTION_MISSING_METHOD); } - // Get a instance of the registry - $userInstance = Registry::getRegistry()->getInstance('user'); - - // Is there an instance? - if (is_null($userInstance)) { - // Get a user instance - $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('guest_class'), $method), array($data)); + // Get a user instance + $userInstance = call_user_func_array(array($this->getConfigInstance()->getConfigEntry('guest_class'), $method), array($data)); - // 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 - throw new UserPasswordMismatchException(array($this, $userInstance), User::EXCEPTION_USER_PASS_MISMATCH); + throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH); } // END - if // Now do the real login. This can be cookie- or session-based login @@ -124,7 +112,7 @@ class ShipSimuGuestLogin 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 */ @@ -137,14 +125,14 @@ class ShipSimuGuestLogin 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: @@ -158,7 +146,7 @@ class ShipSimuGuestLogin 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 }