]> git.mxchange.org Git - shipsimu.git/blobdiff - application/ship-simu/main/login/class_ShipSimuUserLogin.php
Results are now searchable and iterateable, insertDataSet renamed to queryInsertDataS...
[shipsimu.git] / application / ship-simu / main / login / class_ShipSimuUserLogin.php
index 3721fb65f2cb1c622bcf9b8de32086960e2ce23b..a043de8ba74c0ed28cedc5ab4621ebdcd608ab6c 100644 (file)
@@ -66,8 +66,8 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser {
         *                                                                              was detected
         * @throws      MissingMethodException          If a method was not found in the
         *                                                                              User class
-        * @throws      UserEmailMissingException       If user with given email address was
-        *                                                                              not found in database
+        * @throws      UserPasswordMismatchException   If the supplied password did not
+        *                                                                              match with the stored password
         */
        public function doLogin (Requestable $requestInstance) {
                // By default no method is selected
@@ -89,7 +89,7 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser {
                if (is_null($method)) {
                        // Then abort here
                        throw new UserLoginMethodException($this, self::EXCEPTION_MISSING_METHOD);
-               } elseif (!method_exists("User", $method)) {
+               } elseif (!method_exists($this->getConfigInstance()->readConfig('user_class'), $method)) {
                        // The method is invalid!
                        throw new MissingMethodException(array($this, $method), self::EXCEPTION_MISSING_METHOD);
                }
@@ -100,17 +100,25 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser {
                // Is there an instance?
                if (is_null($userInstance)) {
                        // Get a user instance
-                       $userInstance = call_user_func_array(array("User", $method), array($data));
+                       $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('user_class'), $method), array($data));
+
+                       // Remember this new instance in registry
+                       Registry::getRegistry()->addInstance($userInstance);
                } // END - if
 
-               // If we have email login then check if a user account with that email exists!
-               if (($method == "createUserByEmail") && (!$userInstance->ifEmailAddressExists())) {
-                       // The user account is missing!
-                       throw new UserEmailMissingException(array($this, $data), User::EXCEPTION_USER_EMAIL_NOT_FOUND);
+               // Is the password correct?
+               if (!$userInstance->ifPasswordHashMatches($requestInstance)) {
+                       // Mismatching password
+                       throw new UserPasswordMismatchException(array($this, $userInstance), User::EXCEPTION_USER_PASS_MISMATCH);
                } // END - if
 
-               // Partially finished!
-               $this->partialStub("userInstance set, continue with password verification");
+               // Now do the real login. This can be cookie- or session-based login
+               // which depends on the admins setting then on the user's taste.
+               // 1) Get a login helper instance
+               $helperInstance = ObjectFactory::createObjectByConfiguredName('login_helper', array($requestInstance));
+
+               // 2) Execute the login. This will now login...
+               $helperInstance->executeLogin();
        }
 }