]> git.mxchange.org Git - city.git/blobdiff - application/city/main/login/class_CityUserLogin.php
Use testLogin(), if no exception comes the login helper may do the login.
[city.git] / application / city / main / login / class_CityUserLogin.php
index 0957e71784161bb643b8eecf4e332a54c1b69901..9901ee49dd8b4d83ed7129715a9f6aaadc267742 100644 (file)
@@ -21,7 +21,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-class CityUserLogin extends BaseFrameworkSystem implements LoginableUser {
+class CityUserLogin extends BaseFrameworkSystem implements LoginableUser, Registerable {
        /**
         * The hashed password
         */
@@ -65,17 +65,14 @@ class CityUserLogin extends BaseFrameworkSystem implements LoginableUser {
         * @todo        user account.
         */
        public function doLogin (Requestable $requestInstance, Responseable $responseInstance) {
-               // Get member class
-               $userClass = $this->getConfigInstance()->getConfigEntry('user_class');
-
-               // Get a user instance
-               $userInstance = call_user_func_array(array($userClass, 'createMemberByRequest'), array($requestInstance));
+               // Get a user instance from factory
+               $userInstance = UserFactory::createUserByRequest($requestInstance);
 
                // Remember this new instance in registry
                Registry::getRegistry()->addInstance('user', $userInstance);
 
                // Is the password correct?
-               if ($userInstance->ifPasswordHashMatches($requestInstance) === false) {
+               if ($userInstance->ifPasswordHashMatches($requestInstance) === FALSE) {
                        // Mismatching password
                        throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH);
                } // END - if
@@ -94,6 +91,18 @@ class CityUserLogin extends BaseFrameworkSystem implements LoginableUser {
                $helperInstance->executeLogin($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
+        */
+       public function testLogin (Requestable $requestInstance) {
+               // Create a dummy instance
+               $dummyInstance = Member::createMemberByRequest($requestInstance);
+       }
+
        /**
         * Determines wether the login was fine. This is done by checking if 'login' instance is in registry
         *