Пример #1
0
 /**
  * login
  *
  * @param  String  $loginName
  * @param  String  $password
  * @return  Boolean  return true when login success.
  */
 public function login($login = '', $password = '', $anonymous = 0, $push = 0)
 {
     /* test bypass for SSO begin */
     /*
     $user = User::getUserByUsername('testuser');
     $userSession = (get_class($user) == 'wcf\data\user\User' ? $user : new wcf\data\user\User(null, null, $user));
     if ($userSession && $userSession->userID) {
     WCF::getSession()->changeUser($userSession);
     HeaderUtil::setCookie('cookieHash', SessionHandler::getInstance()->sessionID);
     MbqMain::$oMbqAppEnv->oCurrentUser = $userSession;
     $this->initOCurMbqEtUser();
     return true;
     } else {
     return false;
     }
     */
     /* test bypass for SSO end */
     //refer wcf\acp\form\LoginForm::validateUser()
     try {
         $oUser = UserAuthenticationFactory::getInstance()->getUserAuthentication()->loginManually($login, $password);
     } catch (UserInputException $e) {
         if ($e->getField() == 'username') {
             try {
                 $oUser = EmailUserAuthentication::getInstance()->loginManually($login, $password);
             } catch (UserInputException $e2) {
                 //if ($e2->getField() == 'username') throw $e;
                 //throw $e2;
                 //return $e2->getMessage();
             }
         }
         return $e->getMessage();
     }
     if (!$oUser || !$oUser->userID) {
         return false;
     }
     //ref wcf\form\LoginForm::save()
     // set cookies
     //UserAuthenticationFactory::getInstance()->getUserAuthentication()->storeAccessData($oUser, $loginName, $password);
     // change user
     return $this->doneLogin($oUser);
 }
Пример #2
0
 /**
  * login
  *
  * @param  String  $loginName
  * @param  String  $password
  * @return  Boolean  return true when login success.
  */
 public function login($loginName, $password)
 {
     //ref wcf\acp\form\LoginForm::validateUser()
     try {
         $oUser = UserAuthenticationFactory::getInstance()->getUserAuthentication()->loginManually($loginName, $password);
     } catch (UserInputException $e) {
         if ($e->getField() == 'username') {
             try {
                 $oUser = EmailUserAuthentication::getInstance()->loginManually($loginName, $password);
             } catch (UserInputException $e2) {
                 //if ($e2->getField() == 'username') throw $e;
                 //throw $e2;
                 return false;
             }
         } else {
             //throw $e;
             return false;
         }
     }
     if (!$oUser || !$oUser->userID) {
         return false;
     }
     //ref wcf\form\LoginForm::save()
     // set cookies
     UserAuthenticationFactory::getInstance()->getUserAuthentication()->storeAccessData($oUser, $loginName, $password);
     // change user
     WCF::getSession()->changeUser($oUser);
     MbqMain::$oMbqAppEnv->oCurrentUser = $oUser;
     $this->initOCurMbqEtUser();
     return true;
 }
Пример #3
0
	/**
	 * Validates the user access data.
	 */
	protected function validateUser() {
		try {
			$this->user = UserAuthenticationFactory::getInstance()->getUserAuthentication()->loginManually($this->username, $this->password);
		}
		catch (UserInputException $e) {
			// TODO: create an option for the authentication with email address
			if (true) {
				if ($e->getField() == 'username') {
					try {
						$this->user = EmailUserAuthentication::getInstance()->loginManually($this->username, $this->password);
					}
					catch (UserInputException $e2) {
						if ($e2->getField() == 'username') throw $e;
						throw $e2;
					}
				}
				else {
					throw $e;
				}
			}
			else {
				throw $e;
			}
		}
	}
Пример #4
0
 /**
  * Validates the user access data.
  */
 protected function validateUser()
 {
     try {
         $this->user = UserAuthenticationFactory::getInstance()->getUserAuthentication()->loginManually($this->username, $this->password);
     } catch (UserInputException $e) {
         if ($e->getField() == 'username') {
             try {
                 $this->user = EmailUserAuthentication::getInstance()->loginManually($this->username, $this->password);
             } catch (UserInputException $e2) {
                 if ($e2->getField() == 'username') {
                     throw $e;
                 }
                 throw $e2;
             }
         } else {
             throw $e;
         }
     }
 }