]> git.mxchange.org Git - shipsimu.git/blobdiff - application/ship-simu/main/login/helper/class_ShipSimuLoginHelper.php
User login (non-guest) basicly finished, news stubs added, registration and final...
[shipsimu.git] / application / ship-simu / main / login / helper / class_ShipSimuLoginHelper.php
index 9dd7f96fb34a815a11e1b2e6c13a9b8a29af9347..0e9aee1fedb768cc73a6d420f951875a2ca4e2c5 100644 (file)
@@ -33,15 +33,10 @@ class ShipSimuLoginHelper extends BaseLoginHelper implements HelpableLogin {
        /**
         * The login method we shall choose
         */
-       private $loginMethod = "";
-
-       /**
-        * Instance for a request class
-        */
-       private $requestInstance = null;
+       private $authMethod = "";
 
        // Exception constants
-       const EXCEPTION_INVALID_USER_INSTANCE = 0xf00;
+       const EXCEPTION_INVALID_USER_INSTANCE = 0x080;
 
        /**
         * Protected constructor
@@ -80,23 +75,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,28 +90,8 @@ class ShipSimuLoginHelper extends BaseLoginHelper implements HelpableLogin {
         *
         * @return      void
         */
-       protected function setDefaultLoginMethod () {
-               $this->loginMethod = $this->getConfigInstance()->readConfig('login_method');
-       }
-
-       /**
-        * Setter for request instance
-        *
-        * @param       $requestInstance        A Requestable class instance
-        * @return      void
-        */
-       public final function setRequestInstance (Requestable $requestInstance) {
-               $this->requestInstance = $requestInstance;
-       }
-
-       /**
-        * Getter for request instance
-        *
-        * @param       
-        * @return      $requestInstance        A Requestable class instance
-        */
-       public final function getRequestInstance () {
-               return $this->requestInstance;
+       protected function setDefaultAuthMethod () {
+               $this->authMethod = $this->getConfigInstance()->readConfig('auth_method_class');
        }
 
        /**
@@ -142,17 +102,14 @@ 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'));
+               $loginInstance->setUserAuth($this->getRequestInstance()->getRequestElement('username'));
 
                // Set password cookie
-               $loginInstance->setPasswordAuth($this->requestInstance->getRequestElement('pass_hash'));
+               $loginInstance->setPasswordAuth($this->getRequestInstance()->getRequestElement('pass_hash'));
 
                // Remember this login instance for later usage
                Registry::getRegistry()->addInstance('login', $loginInstance);