<commit_before><?php

class OAuthModel {

    protected $_db;
    protected $base;
    protected $version;

    /**
     * Object constructor, sets up the db and some objects need request too
     *
     * @param PDO     $db      The database connection handle
     */
    public function __construct(PDO $db, Request $request) {
        $this->_db     = $db;
        $this->base    = $request->base;
        $this->version = $request->version;
    }

    /**
     * verifyAccessToken
     *
     * @param string $token The valid access token
     * @access public
     * @return int The ID of the user this belongs to
     */
    public function verifyAccessToken($token) {
        $sql = 'select id, user_id from oauth_access_tokens'
            . ' where access_token=:access_token';
        $stmt = $this->_db->prepare($sql);
        $stmt->execute(array("access_token" => $token));
        $result = $stmt->fetch();

        // log that we used this token
        $update_sql = 'update oauth_access_tokens '
            . ' set last_used_date = NOW()'
            . ' where id = :id';
        $update_stmt = $this->_db->prepare($update_sql);
        $update_stmt->execute(array("id" => $result['id']));

        // return the user ID this token belongs to
        return $result['user_id'];
    }


    /**
     * Create an access token for a username or password
     *
     * @param  string $clientId aka consumer_key
     * @param  string $username username
     * @param  string $password password
     * @return string           access token
     */
    public function createAccessTokenFromPassword($clientId, $username, $password)
    {
        // is the username/password combination correct?
        $userId = $this->getUserId($username, $password);
        if (!$userId) {
            return false;
        }

        // expire old tokens (Does this need to be in a different place?)
        $this->expireOldTokens($clientId);

        // remove current token for this client if there is one - i.e
        // re-logging in causes the current token to be expired.
        $this->removeTokenForUser($clientId, $userId);

        // create new token
        $accessToken = $this->newAccessToken($clientId, $userId);
<commit_msg>remove the call to delete same user/client tokens<commit_after><?php

class OAuthModel {

    protected $_db;
    protected $base;
    protected $version;

    /**
     * Object constructor, sets up the db and some objects need request too
     *
     * @param PDO     $db      The database connection handle
     */
    public function __construct(PDO $db, Request $request) {
        $this->_db     = $db;
        $this->base    = $request->base;
        $this->version = $request->version;
    }

    /**
     * verifyAccessToken
     *
     * @param string $token The valid access token
     * @access public
     * @return int The ID of the user this belongs to
     */
    public function verifyAccessToken($token) {
        $sql = 'select id, user_id from oauth_access_tokens'
            . ' where access_token=:access_token';
        $stmt = $this->_db->prepare($sql);
        $stmt->execute(array("access_token" => $token));
        $result = $stmt->fetch();

        // log that we used this token
        $update_sql = 'update oauth_access_tokens '
            . ' set last_used_date = NOW()'
            . ' where id = :id';
        $update_stmt = $this->_db->prepare($update_sql);
        $update_stmt->execute(array("id" => $result['id']));

        // return the user ID this token belongs to
        return $result['user_id'];
    }


    /**
     * Create an access token for a username or password
     *
     * @param  string $clientId aka consumer_key
     * @param  string $username username
     * @param  string $password password
     * @return string           access token
     */
    public function createAccessTokenFromPassword($clientId, $username, $password)
    {
        // is the username/password combination correct?
        $userId = $this->getUserId($username, $password);
        if (!$userId) {
            return false;
        }

        // expire old tokens (Does this need to be in a different place?)
        $this->expireOldTokens($clientId);

        // create new token
        $accessToken = $this->newAccessToken($clientId, $userId);

{'fraction_non_alphanumeric': 0.11560693641618497, 'fraction_numerical': 0.0, 'mean_word_length': 2.185567010309278, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 38, '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': '3918409', 'n_tokens_mistral': 1200, 'n_tokens_neox': 1188, 'n_words': 365}