original_string: protected function authorizeBlock()
      {
          try {
              $select = $this->db->select();
              $select->from('gems__user_login_attempts', new \Zend_Db_Expr('UNIX_TIMESTAMP(gula_block_until) - UNIX_TIMESTAMP() AS wait'))
                      ->where('gula_block_until is not null')
                      ->where('gula_login = ?', $this->getLoginName())
                      ->where('gula_id_organization = ?', $this->getCurrentOrganizationId())
                      ->limit(1);
  
              // Not the first login
              if ($block = $this->db->fetchOne($select)) {
                  if ($block > 0) {
                      $minutes = intval($block / 60) + 1;
  
                      // Report all is not well
                      return sprintf($this->plural('Your account is temporarily blocked, please wait a minute.', 'Your account is temporarily blocked, please wait %d minutes.', $minutes), $minutes);
  
                  } else {
                      // Clean the block once it's past
                      $values['gula_failed_logins'] = 0;
                      $values['gula_last_failed']   = null;
                      $values['gula_block_until']   = null;
                      $where = $this->db->quoteInto('gula_login = ? AND ', $this->getLoginName());
                      $where .= $this->db->quoteInto('gula_id_organization = ?', $this->getCurrentOrganizationId());
  
                      $this->db->update('gems__user_login_attempts', $values, $where);
                  }
              }
  
          } catch (\Zend_Db_Exception $e) {
              // Fall through as this does not work if the database upgrade did not run
              // \MUtil_Echo::r($e);
          }
  
          return true;
      }
code: protected function authorizeBlock()
      {
          try {
              $select = $this->db->select();
              $select->from('gems__user_login_attempts', new \Zend_Db_Expr('UNIX_TIMESTAMP(gula_block_until) - UNIX_TIMESTAMP() AS wait'))
                      ->where('gula_block_until is not null')
                      ->where('gula_login = ?', $this->getLoginName())
                      ->where('gula_id_organization = ?', $this->getCurrentOrganizationId())
                      ->limit(1);
  
              // Not the first login
              if ($block = $this->db->fetchOne($select)) {
                  if ($block > 0) {
                      $minutes = intval($block / 60) + 1;
  
                      // Report all is not well
                      return sprintf($this->plural('Your account is temporarily blocked, please wait a minute.', 'Your account is temporarily blocked, please wait %d minutes.', $minutes), $minutes);
  
                  } else {
                      // Clean the block once it's past
                      $values['gula_failed_logins'] = 0;
                      $values['gula_last_failed']   = null;
                      $values['gula_block_until']   = null;
                      $where = $this->db->quoteInto('gula_login = ? AND ', $this->getLoginName());
                      $where .= $this->db->quoteInto('gula_id_organization = ?', $this->getCurrentOrganizationId());
  
                      $this->db->update('gems__user_login_attempts', $values, $where);
                  }
              }
  
          } catch (\Zend_Db_Exception $e) {
              // Fall through as this does not work if the database upgrade did not run
              // \MUtil_Echo::r($e);
          }
  
          return true;
      }
code_tokens: protected function authorizeBlock ( ) { try { $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__user_login_attempts' , new \ Zend_Db_Expr ( 'UNIX_TIMESTAMP(gula_block_until) - UNIX_TIMESTAMP() AS wait' ) ) -> where ( 'gula_block_until is not null' ) -> where ( 'gula_login = ?' , $ this -> getLoginName ( ) ) -> where ( 'gula_id_organization = ?' , $ this -> getCurrentOrganizationId ( ) ) -> limit ( 1 ) ; // Not the first login if ( $ block = $ this -> db -> fetchOne ( $ select ) ) { if ( $ block > 0 ) { $ minutes = intval ( $ block / 60 ) + 1 ; // Report all is not well return sprintf ( $ this -> plural ( 'Your account is temporarily blocked, please wait a minute.' , 'Your account is temporarily blocked, please wait %d minutes.' , $ minutes ) , $ minutes ) ; } else { // Clean the block once it's past $ values [ 'gula_failed_logins' ] = 0 ; $ values [ 'gula_last_failed' ] = null ; $ values [ 'gula_block_until' ] = null ; $ where = $ this -> db -> quoteInto ( 'gula_login = ? AND ' , $ this -> getLoginName ( ) ) ; $ where .= $ this -> db -> quoteInto ( 'gula_id_organization = ?' , $ this -> getCurrentOrganizationId ( ) ) ; $ this -> db -> update ( 'gems__user_login_attempts' , $ values , $ where ) ; } } } catch ( \ Zend_Db_Exception $ e ) { // Fall through as this does not work if the database upgrade did not run // \MUtil_Echo::r($e); } return true ; }
docstring: Checks if the user is allowed to login or is blocked
  
  An adapter authorizes and if the end resultis boolean, string or array
  it is converted into a Zend\Authenticate\Result.
  
  @return mixed Zend\Authentication\Adapter\AdapterInterface|Zend\Authenticate\Result|boolean|string|array
docstring_tokens: Checks if the user is allowed to login or is blocked