/**
* The login method we shall choose
*/
- private $loginMethod = "";
+ private $authMethod = "";
/**
* Instance for a request class
private $requestInstance = null;
// Exception constants
- const EXCEPTION_INVALID_USER_INSTANCE = 0xf00;
+ const EXCEPTION_INVALID_USER_INSTANCE = 0x080;
/**
* Protected constructor
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);
*
* @return void
*/
- protected function setDefaultLoginMethod () {
- $this->loginMethod = $this->getConfigInstance()->readConfig('login_method');
+ protected function setDefaultAuthMethod () {
+ $this->authMethod = $this->getConfigInstance()->readConfig('auth_method_class');
}
/**
* @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'));