]> 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 7caea517ce48879a22e73c06fc8020e6aceceacb..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
@@ -101,16 +101,24 @@ class ShipSimuUserLogin extends BaseFrameworkSystem implements LoginableUser {
                if (is_null($userInstance)) {
                        // Get a user instance
                        $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();
        }
 }