]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/filter/auth/class_UserAuthFilter.php
Ship-Simu now has its own member/guest implementations
[shipsimu.git] / inc / classes / main / filter / auth / class_UserAuthFilter.php
index 25641dc3b90b6debc00e26d57d685d303c021857..572d2b0f2eb1df4ac542af6baec01ae071c122d4 100644 (file)
@@ -79,6 +79,7 @@ class UserAuthFilter extends BaseFilter implements Filterable {
         * @return      void
         * @throws      UserAuthorizationException      If the auth login was not found or if it was invalid
         * @throws      UserPasswordMismatchException   If the supplied password hash does not match
+        * @throws      ClassNotFoundException  If the user (guest/member) class was not found
         */
        public function execute (Requestable $requestInstance, Responseable $responseInstance) {
                // Then get an auth instance for checking and updating the auth cookies
@@ -108,13 +109,24 @@ class UserAuthFilter extends BaseFilter implements Filterable {
 
                // Now, try to get a user or guest instance
                if ($authLogin == $this->getConfigInstance()->readConfig('guest_login_user')) {
-                       // Guest login!
-                       $userInstance = Guest::createGuestByUserName($authLogin);
+                       // Set class
+                       $className = $this->getConfigInstance()->readConfig('guest_class');
+                       $methodName = 'createGuestByUserName';
                } else {
                        // Regular user account
-                       $userInstance = Member::createUserByUserName($authLogin);
+                       $className = $this->getConfigInstance()->readConfig('user_class');
+                       $methodName = 'createMemberByUserName';
                }
 
+               // Does the guest class exist?
+               if (!class_exists($className)) {
+                       // Then abort here
+                       throw new ClassNotFoundException (array($this, $className), self::EXCEPTION_CLASS_NOT_FOUND);
+               } // END - if
+
+               // Now try the dynamic login
+               $userInstance = call_user_func_array(array($className, $methodName), array($authLogin));
+
                // Is the password correct?
                if ($userInstance->getPasswordHash() !== $authHash) {
                        // Mismatching password