Exemplo n.º 1
0
 public function indexAction()
 {
     $settings = new Model_Settings();
     $this->view->maintenanceEnabled = $settings->isMaintenanceMode();
     $authAttempts = new Users_Model_AuthAttempts();
     $attempt = $authAttempts->get();
     $this->view->useCaptcha = $attempt && $attempt->surpassedMaxAllowed();
     $this->view->loginForm = new Users_Form_Login(null, $this->view->base, $this->view->useCaptcha);
     if ($this->_config->SSL->enable_mixed_mode) {
         if ($this->_config->subdomain->enabled) {
             // in this case $this->view->base contains the full URL, so we just gotta replace the protocol
             $this->view->loginTargetBase = 'https' . substr($this->view->base, strpos($this->view->base, '://'));
         } else {
             $this->view->loginTargetBase = 'https://' . $_SERVER['HTTP_HOST'] . $this->view->base;
         }
     } else {
         $this->view->loginTargetBase = $this->view->base;
     }
     $this->view->allowRegistrations = $this->_config->environment->registrations_enabled;
     if ($this->user->role == Users_Model_User::ROLE_GUEST && @$_COOKIE['image']) {
         $images = new Users_Model_SigninImages();
         $this->view->image = $images->getByCookie($_COOKIE['image']);
     } else {
         $this->view->image = false;
     }
     $this->view->yubikey = $this->_config->yubikey;
     $this->_helper->viewRenderer->setResponseSegment('sidebar');
 }
 public function imageAction()
 {
     $this->_helper->viewRenderer->setNeverRender(true);
     $this->_helper->layout->disableLayout();
     $images = new Users_Model_SigninImages();
     if ($cookie = $this->_request->getParam('id')) {
         $image = $images->getByCookie($cookie);
     } else {
         if ($this->user->role != Users_Model_User::ROLE_GUEST) {
             $image = $images->getForUser($this->user);
         } else {
             return;
         }
     }
     $this->_response->setHeader('Content-type', $image->mime);
     echo $image->image;
 }
Exemplo n.º 3
0
 public function getImage()
 {
     if (!isset($this->_image)) {
         $images = new Users_Model_SigninImages();
         if (!($row = $images->getForUser($this))) {
             $this->_image = false;
         } else {
             $this->_image = $row;
         }
     }
     return $this->_image;
 }
Exemplo n.º 4
0
 /**
  * We don't use the session with the login form to simplify the dynamic appearance of the captcha
  */
 public function loginAction()
 {
     $server = $this->_getOpenIdProvider();
     $request = $server->decodeRequest();
     $this->view->yubikey = $this->_config->yubikey;
     $authAttempts = new Users_Model_AuthAttempts();
     $attempt = $authAttempts->get();
     $this->view->useCaptcha = $attempt && $attempt->surpassedMaxAllowed();
     $this->view->form = new Form_OpenidLogin(null, $this->view->base, $attempt && $attempt->surpassedMaxAllowed());
     if ($this->_getParam('invalidCaptcha')) {
         $this->view->form->captcha->addError($this->view->translate('Captcha value is wrong'));
     }
     if ($this->_getParam('invalidLogin')) {
         $this->view->form->addError($this->view->translate('Invalid credentials'));
     }
     if ($request->idSelect()) {
         $this->view->identity = false;
         $this->view->form->openIdIdentity->setRequired(true);
     } else {
         $this->view->identity = $request->identity;
     }
     $this->view->queryString = $this->_queryString();
     if ($this->user->role == Users_Model_User::ROLE_GUEST && @$_COOKIE['image']) {
         $images = new Users_Model_SigninImages();
         $this->view->image = $images->getByCookie($_COOKIE['image']);
     } else {
         $this->view->image = false;
     }
 }