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 c9906c80267df92ddf9f826e68fc793af1e7ecd5..d1c26b3232017175ebb1e811c2dcca34be3f42e0 100644 (file)
@@ -32,6 +32,15 @@ interface LoginableUser extends FrameworkInterface {
         * @return      void
         */
        function doLogin (Requestable $requestInstance, Responseable $responseInstance);
         * @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]
 }
 
 // [EOF]
index 2e42a794b12018efe454f560730ca1a54d9e6d3a..a6302248089ed686a575d802bdf31cbef9c6c08e 100644 (file)
@@ -1948,7 +1948,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        protected final function getDatabaseEntry () {
                // Is there an instance?
         */
        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
                        // Throw an exception here
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
                } // END - if
index 63db93d5d3f76febae3afbf7294942b1549f0e58..3faf50eb7e0b7a6edcbb708ff181f273663b5a2f 100644 (file)
@@ -50,10 +50,16 @@ class LoginFactory extends ObjectFactory {
                        // Probe on member instance
                        try {
                                // Try to instance member login class
                        // 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
                        } 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
                        }
 
                        // Set the instance in registry for further use
index c87a3a3f21e3ea4a2986ddee90fd0d6db46de1d9..256bf3d6a8c6ca3c06d0c0d9ec9517a6aee82e20 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
                        // 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
                                $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 ce67c061f9128cbde18ffbbae13484eb093e6698..bc7988a4990b744e3aad2234dc951475457ec990 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_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
 
        /**
         * Username of current user
@@ -121,7 +122,7 @@ class BaseUser extends BaseFrameworkSystem implements Updateable {
                $exists = FALSE;
 
                // Is a previous result there?
                $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');
 
                        // 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?
                $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');
 
                        // 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?
                $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');
 
                        // Get a UserDatabaseWrapper instance
                        $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
 
index b88b55be59c9364c68c394b1a135e8917e73e7b2..1e4a9696b5272fe1349b734f1ccc2667dbf029dc 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 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
                }
 
                // Return the instance