]> git.mxchange.org Git - shipsimu.git/blobdiff - application/ship-simu/main/login/helper/class_ShipSimuLoginHelper.php
Login and auth classes added. WARNING: All class config entries must end with _class!
[shipsimu.git] / application / ship-simu / main / login / helper / class_ShipSimuLoginHelper.php
index 9dd7f96fb34a815a11e1b2e6c13a9b8a29af9347..169f18fbdd5242973893e947282bd412eef26170 100644 (file)
@@ -33,7 +33,7 @@ class ShipSimuLoginHelper extends BaseLoginHelper implements HelpableLogin {
        /**
         * The login method we shall choose
         */
-       private $loginMethod = "";
+       private $authMethod = "";
 
        /**
         * Instance for a request class
@@ -41,7 +41,7 @@ class ShipSimuLoginHelper extends BaseLoginHelper implements HelpableLogin {
        private $requestInstance = null;
 
        // Exception constants
-       const EXCEPTION_INVALID_USER_INSTANCE = 0xf00;
+       const EXCEPTION_INVALID_USER_INSTANCE = 0x080;
 
        /**
         * Protected constructor
@@ -80,23 +80,8 @@ class ShipSimuLoginHelper extends BaseLoginHelper implements HelpableLogin {
                        throw new UserInstanceMissingException (array($helperInstance, 'user'), self::EXCEPTION_INVALID_USER_INSTANCE);
                } // END - if
 
-               // Get the login method from request
-               $methodRequest = $requestInstance->getRequestElement('login_method');
-
-               // Now, if that wents fine we can check if the request includes a login method entry
-               if ((!is_null($methodRequest)) && ($methodRequest != "default") && ($methodRequest != $userInstance->getLoginMethod())) {
-                       // Okay, the login method has been choosen by user so remember it
-                       $helperInstance->setLoginMethod($methodRequest);
-
-                       // Remeber that we need to update the user account as well
-                       $userInstance->addUpdateData('login_method', $methodRequest);
-               } elseif (($methodRequest == "default") && (is_string($userInstance->getLoginMethod()))) {
-                       // Choose default method from user
-                       $helperInstance->setLoginMethod($userInstance->getLoginMethod());
-               } else {
-                       // Set default login method from config
-                       $helperInstance->setDefaultLoginMethod();
-               }
+               // Set default login method from config
+               $helperInstance->setDefaultAuthMethod();
 
                // Set request instance
                $helperInstance->setRequestInstance($requestInstance);
@@ -110,8 +95,8 @@ class ShipSimuLoginHelper extends BaseLoginHelper implements HelpableLogin {
         *
         * @return      void
         */
-       protected function setDefaultLoginMethod () {
-               $this->loginMethod = $this->getConfigInstance()->readConfig('login_method');
+       protected function setDefaultAuthMethod () {
+               $this->authMethod = $this->getConfigInstance()->readConfig('auth_method_class');
        }
 
        /**
@@ -142,11 +127,8 @@ class ShipSimuLoginHelper extends BaseLoginHelper implements HelpableLogin {
         * @return      void
         */
        public function executeLogin (Responseable $responseInstance) {
-               // First create the requested login method name
-               $loginMethodClass = ucfirst(strtolower($this->loginMethod)) . "Login";
-
-               // Then try to get an instance from it
-               $loginInstance = ObjectFactory::createObjectByName($loginMethodClass, array($responseInstance));
+               // Get an instance from the login method
+               $loginInstance = ObjectFactory::createObjectByName($this->authMethod, array($responseInstance));
 
                // Set user cookie
                $loginInstance->setUserAuth($this->requestInstance->getRequestElement('username'));