Beispiel #1
0
 public static function processCookies()
 {
     if (isset($_COOKIE['feAutologin']) && !Kwf_Auth::getInstance()->getStorage()->read()) {
         Kwf_Util_Https::ensureHttps();
         $feAutologin = explode('.', $_COOKIE['feAutologin']);
         if (count($feAutologin) == 2) {
             $adapter = new Kwf_Auth_Adapter_PasswordAuth();
             $adapter->setIdentity($feAutologin[0]);
             $adapter->setCredential($feAutologin[1]);
             $adapter->setUseCookieToken(true);
             $auth = Kwf_Auth::getInstance();
             $auth->clearIdentity();
             $result = $auth->authenticate($adapter);
             if (!$result->isValid()) {
                 self::clearCookies();
             }
         }
     } else {
         if (isset($_COOKIE['hasFeAutologin']) && !Kwf_Auth::getInstance()->getStorage()->read()) {
             //feAutologin cookie is set with https-only (for security reasons)
             //hasFeAutologin is seth without https-only
             Kwf_Util_Https::ensureHttps();
         }
     }
 }
 private function _getAuthenticateResult($identity, $credential)
 {
     $adapter = new Kwf_Auth_Adapter_PasswordAuth();
     $adapter->setIdentity($identity);
     $adapter->setCredential($credential);
     $auth = Kwf_Auth::getInstance();
     $auth->clearIdentity();
     return $auth->authenticate($adapter);
 }
 public static function processCookies()
 {
     if (isset($_COOKIE['feAutologin']) && !Kwf_Auth::getInstance()->getStorage()->read()) {
         $feAutologin = explode('.', $_COOKIE['feAutologin']);
         if (count($feAutologin) == 2) {
             $adapter = new Kwf_Auth_Adapter_PasswordAuth();
             $adapter->setIdentity($feAutologin[0]);
             $adapter->setCredential($feAutologin[1]);
             $adapter->setUseCookieToken(true);
             $auth = Kwf_Auth::getInstance();
             $auth->clearIdentity();
             $result = $auth->authenticate($adapter);
             if (!$result->isValid()) {
                 self::clearCookies();
             }
         }
     }
 }
 protected function _afterSave($row)
 {
     $row = $this->_getParam('row');
     $adapter = new Kwf_Auth_Adapter_PasswordAuth();
     $auth = Kwf_Auth::getInstance();
     $adapter->setIdentity($row->email);
     $adapter->setCredential($row->password);
     $result = $auth->authenticate($adapter);
     if ($result->isValid()) {
         $redirectUrl = '/' . ltrim($this->getRequest()->getPathInfo(), '/');
         if ($this->_getParam('redirect') && substr($this->_getParam('redirect'), 0, 1) == '/') {
             $redirectUrl = $this->_getParam('redirect');
         }
         $this->redirect($redirectUrl);
     } else {
         $errors = $this->getRequest()->getParam('formErrors');
         foreach ($result->getMessages() as $msg) {
             $errors[] = array('message' => $msg);
         }
         $this->getRequest()->setParam('formErrors', $errors);
         $this->_showForm();
     }
 }