More fixes ...
authorRoland Haeder <roland@mxchange.org>
Sat, 18 Apr 2015 11:03:27 +0000 (13:03 +0200)
committerRoland Haeder <roland@mxchange.org>
Sat, 18 Apr 2015 11:03:27 +0000 (13:03 +0200)
Signed-off-by: Roland H├Ąder <roland@mxchange.org>
inc/classes/interfaces/login/class_LoginableUser.php
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/factories/login/class_LoginFactory.php
inc/classes/main/filter/validator/class_UserNameValidatorFilter.php
inc/classes/main/user/class_BaseUser.php
inc/classes/main/user/member/class_Member.php

index c9906c8..d1c26b3 100644 (file)
@@ -32,6 +32,15 @@ interface LoginableUser extends FrameworkInterface {
         * @return      void
         */
        function doLogin (Requestable $requestInstance, Responseable $responseInstance);
+
+       /**
+        * Check if the implementation is correct. Only the request instance is
+        * needed as no redirect is done here.
+        *
+        * @param       $requestInstance        An instance of a Requestable class
+        * @return
+        */
+       function testLogin (Requestable $requestInstance);
 }
 
 // [EOF]
index 2e42a79..a630224 100644 (file)
@@ -1948,7 +1948,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        protected final function getDatabaseEntry () {
                // Is there an instance?
-               if (is_null($this->getResultInstance())) {
+               if (!$this->getResultInstance() instanceof SearchableResult) {
                        // Throw an exception here
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
                } // END - if
index 63db93d..3faf50e 100644 (file)
@@ -50,10 +50,16 @@ class LoginFactory extends ObjectFactory {
                        // Probe on member instance
                        try {
                                // Try to instance member login class
-                               $loginInstance = self::createObjectByConfiguredName('user_login_class', array($requestInstance));
+                               $loginInstance = self::createObjectByConfiguredName('user_login_class');
+
+                               // Test login
+                               $loginInstance->testLogin($requestInstance);
                        } catch (UnexpectedGuestAccountException $e) {
                                // Then try guest login
-                               $loginInstance = self::createObjectByConfiguredName('guest_login_class', array($requestInstance));
+                               $loginInstance = self::createObjectByConfiguredName('guest_login_class');
+
+                               // Test login again
+                               $loginInstance->testLogin($requestInstance);
                        }
 
                        // Set the instance in registry for further use
index c87a3a3..256bf3d 100644 (file)
@@ -115,7 +115,6 @@ class UserNameValidatorFilter extends BaseFilter implements Filterable {
                        // If this instance is created then the username *does* exist
                        try {
                                // Get a new instance
-
                                $userInstance = call_user_func_array(array($this->getConfigInstance()->getConfigEntry('user_class'), 'createMemberByUsername'), array($userName));
 
                                // Remember this user instance in our registry for later usage
index ce67c06..bc7988a 100644 (file)
@@ -26,6 +26,7 @@ class BaseUser extends BaseFrameworkSystem implements Updateable {
        const EXCEPTION_USERNAME_NOT_FOUND   = 0x150;
        const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x151;
        const EXCEPTION_USER_PASS_MISMATCH   = 0x152;
+       const EXCEPTION_USER_IS_GUEST        = 0x153;
 
        /**
         * Username of current user
@@ -121,7 +122,7 @@ class BaseUser extends BaseFrameworkSystem implements Updateable {
                $exists = FALSE;
 
                // Is a previous result there?
-               if (is_null($this->getResultInstance())) {
+               if (!$this->getResultInstance() instanceof SearchableResult) {
                        // Get a UserDatabaseWrapper instance
                        $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
 
@@ -165,7 +166,7 @@ class BaseUser extends BaseFrameworkSystem implements Updateable {
                $exists = FALSE;
 
                // Is a previous result there?
-               if (is_null($this->getResultInstance())) {
+               if (!$this->getResultInstance() instanceof SearchableResult) {
                        // Get a UserDatabaseWrapper instance
                        $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
 
@@ -220,7 +221,7 @@ class BaseUser extends BaseFrameworkSystem implements Updateable {
                $matches = FALSE;
 
                // Is a previous result there?
-               if (is_null($this->getResultInstance())) {
+               if ((!$this->getResultInstance() instanceof SearchableResult) || ($this->getResultInstance()->count() == 0)) {
                        // Get a UserDatabaseWrapper instance
                        $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
 
index b88b55b..1e4a969 100644 (file)
@@ -55,7 +55,7 @@ class Member extends BaseUser implements ManageableMember, Registerable {
                        throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND);
                } elseif ($userInstance->isGuest() === TRUE) {
                        // User should not be a guest here
-                       throw new UnexpectedGuestAccountException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND);
+                       throw new UnexpectedGuestAccountException(array($userInstance, $userName), self::EXCEPTION_USER_IS_GUEST);
                }
 
                // Return the instance