<commit_before><?php

/**
 * basicAuthenticator class
 *
 * This class provides methods for HTTP Basic authentication
 *
 * @author Anakeen 2009
 * @version $Id: Class.basicAuthenticator.php,v 1.3 2009/01/16 13:33:00 jerome Exp $
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 * @package WHAT
 * @subpackage
 */
 /**
 */
include_once('WHAT/Class.Authenticator.php');

Class openAuthenticator extends Authenticator {

  private $privatelogin=false;
  
  /**
   * no need to ask authentication
   */
  public function checkAuthentication() {    
    include_once('WHAT/Lib.Http.php');

    $privatekey=getHttpVars("privateid");
    if (! $privatekey) return false;

    $login = $this->getLoginFromPrivateKey($privatekey);
    if( $login === false ) {
      return false;
    }

    $err = $this->consumeToken($privatekey);
    if( $err === false ) {
      return false;
    }

    return $login;
  }

  public function getLoginFromPrivateKey($privatekey) {
    include_once('WHAT/Class.UserToken.php');
    include_once('WHAT/Class.User.php');

    $token = new UserToken('', $privatekey);
    if( ! is_object($token) || ! $token->isAffected() ) {
      error_log(__CLASS__."::".__FUNCTION__." ".sprintf("Token '%s' not found.", $privatekey));
      return false;
    }

    $uid = $token->userid;
    $user = new User('', $uid);
    if( ! is_object($user) || ! $user->isAffected() ) {
      error_log(__CLASS__."::".__FUNCTION__." ".sprintf("Could not get user with uid '%s' for token '%s'.", $uid, $privatekey));
      return false;
    }

    return $user->login;
  }<commit_msg>Fixed this->privatelogin (refs #165)<commit_after><?php

/**
 * basicAuthenticator class
 *
 * This class provides methods for HTTP Basic authentication
 *
 * @author Anakeen 2009
 * @version $Id: Class.basicAuthenticator.php,v 1.3 2009/01/16 13:33:00 jerome Exp $
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 * @package WHAT
 * @subpackage
 */
 /**
 */
include_once('WHAT/Class.Authenticator.php');

Class openAuthenticator extends Authenticator {

  private $privatelogin=false;
  
  /**
   * no need to ask authentication
   */
  public function checkAuthentication() {    
    include_once('WHAT/Lib.Http.php');

    $privatekey=getHttpVars("privateid");
    if (! $privatekey) return false;

    $this->privatelogin = $this->getLoginFromPrivateKey($privatekey);
    if( $this->privatelogin === false ) {
      return false;
    }

    $err = $this->consumeToken($privatekey);
    if( $err === false ) {
      return false;
    }

    return $this->privatelogin;
  }

  public function getLoginFromPrivateKey($privatekey) {
    include_once('WHAT/Class.UserToken.php');
    include_once('WHAT/Class.User.php');

    $token = new UserToken('', $privatekey);
    if( ! is_object($token) || ! $token->isAffected() ) {
      error_log(__CLASS__."::".__FUNCTION__." ".sprintf("Token '%s' not found.", $privatekey));
      return false;
    }

    $uid = $token->userid;
    $user = new User('', $uid);
    if( ! is_object($user) || ! $user->isAffected() ) {
      error_log(__CLASS__."::".__FUNCTION__." ".sprintf("Could not get user with uid '%s' for token '%s'.", $uid, $privatekey));
      return false;
    }

    return $user->login;
  }
{'fraction_non_alphanumeric': 0.16271289537712896, 'fraction_numerical': 0.013077858880778588, 'mean_word_length': 3.3970588235294117, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '362881', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1056, 'n_words': 229}