X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=application%2Fship-simu%2Fmain%2Flogin%2Fclass_ShipSimuUserLogin.php;h=72471e586efcae38328d832f8ad74966cb0f02f9;hb=758554bdbe167d7503552e086f7955a5e851f657;hp=1e094cb86c45a44ebf7c33f724f99fdd4edf01e2;hpb=6be6431d3160e268c6e0bce8a8905056d007a6bb;p=shipsimu.git diff --git a/application/ship-simu/main/login/class_ShipSimuUserLogin.php b/application/ship-simu/main/login/class_ShipSimuUserLogin.php index 1e094cb..72471e5 100644 --- a/application/ship-simu/main/login/class_ShipSimuUserLogin.php +++ b/application/ship-simu/main/login/class_ShipSimuUserLogin.php @@ -68,10 +68,6 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser { * @param $requestInstance An instance of a Requestable class * @param $responseInstance An instance of a Responseable class * @return void - * @throws UserAuthMethodException If wether username nor email login - * was detected - * @throws MissingMethodException If a method was not found in the - * User class * @throws UserPasswordMismatchException If the supplied password did not * match with the stored password * @todo We need to add something here which will make more than one @@ -83,33 +79,13 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser { $method = null; $data = ""; - // Detect login method (username or email) and try to get a userinstance - if (!is_null($requestInstance->getRequestElement('username'))) { - // Username found! - $method = "createUserByUsername"; - $data = $requestInstance->getRequestElement('username'); - } elseif (!is_null($requestInstance->getRequestElement('email'))) { - // Email found! - $method = "createUserByEmail"; - $data = $requestInstance->getRequestElement('email'); - } - - // 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('user_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('user_class'), $method), array($data)); + $userInstance = User::createUserByRequest($requestInstance); // Remember this new instance in registry Registry::getRegistry()->addInstance($userInstance);