<commit_before><?php
/**
 * This file is part of the Safan package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Authentication\Drivers;

use Authentication\Classes\AuthBase;
use Authentication\DependencyInjection\Configuration;
use Authentication\Exceptions\ClientDataException;
use Authentication\Exceptions\MemcacheNotFoundException;
use Authentication\Models\GroupBase;
use Authentication\Models\GroupRoleBase;
use Authentication\Models\RoleBase;
use Authentication\Models\UserGroupBase;
use Safan\Safan;

class MemcacheAuth extends AuthBase
{
    /**
     * @var string
     */
    private $hashKey;

    /**
     * @var bool
     */
    private $crossDomain = false;

    /**
     * @var string
     */
    private $crossDomainUrl = '';

    /**
     * @var boolean
     */
    private $ipChecker = false;

    /**
     * @var string
     */
    private $model = '';

    /**
     * User id, by default 0 (no authenticated)
     *
     * @var
     */
    private $userID = 0;

    /**
     * Remember property for login
     *
     * @var bool
     */
    private $isRemember = false;

    /**
     * Cookie Hash name
     *
     * @var string
     */
    private $cookieHashPrefix = 'ma_chp';

    /**
     * Cookie Hash name
     *
     * @var string
     */
    private $cookieUserIDPrefix = 'ma_c_id';

    /**
     * Memcache user prefix
     * Full key e.g. - $this->hashKey . 'mem_user_1'
     *
     * @var string
     */
    private $memcacheUserPrefix = '_mem_user';

    /**
     * Memcache key timeout (1 day)
     */
    const MEMCACHE_CODE_TIMEOUT = 50400;

    /**
     * Cookie timeout for remember (1 year)
     */
    const COOKIE_LONG_DATE = 31536000;

    /**
     * Cookie actually timeout  (3 day)
     */
    const COOKIE_SHORT_DATE = 151200;

    /**
     * @param  Configuration $config
     * @throws MemcacheNotFoundException
     */
    public function __construct(Configuration $config){
        if(!class_exists('Memcache'))
            throw new MemcacheNotFoundException();

        // set hash
        $this->hashKey        = $config->getHashKey();
        $this->crossDomain    = $config->getCrossDomain();
        $this->crossDomainUrl = $config->getCrossDomainUrl();
        $this->ipChecker      = $config->isIpCheckerEnabled();
        $this->model          = $config->getModel();
    }

    /**
     * @param $email
     * @param $password
     * @param bool $rememberMe
     * @return mixed|void
     */
    public function login($email, $password, $rememberMe = true){
        // get model and find user
        $userModel = call_user_func([$this->model, 'instance']);
        $user      = $userModel->where(['email' => $email])->runOnce();

        if(is_null($user))
            return false;
<commit_msg>Add alternative parameter for login<commit_after><?php
/**
 * This file is part of the Safan package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Authentication\Drivers;

use Authentication\Classes\AuthBase;
use Authentication\DependencyInjection\Configuration;
use Authentication\Exceptions\ClientDataException;
use Authentication\Exceptions\MemcacheNotFoundException;
use Authentication\Models\GroupBase;
use Authentication\Models\GroupRoleBase;
use Authentication\Models\RoleBase;
use Authentication\Models\UserGroupBase;
use Safan\Safan;

class MemcacheAuth extends AuthBase
{
    /**
     * @var string
     */
    private $hashKey;

    /**
     * @var bool
     */
    private $crossDomain = false;

    /**
     * @var string
     */
    private $crossDomainUrl = '';

    /**
     * @var boolean
     */
    private $ipChecker = false;

    /**
     * @var string
     */
    private $model = '';

    /**
     * User id, by default 0 (no authenticated)
     *
     * @var
     */
    private $userID = 0;

    /**
     * Remember property for login
     *
     * @var bool
     */
    private $isRemember = false;

    /**
     * Cookie Hash name
     *
     * @var string
     */
    private $cookieHashPrefix = 'ma_chp';

    /**
     * Cookie Hash name
     *
     * @var string
     */
    private $cookieUserIDPrefix = 'ma_c_id';

    /**
     * Memcache user prefix
     * Full key e.g. - $this->hashKey . 'mem_user_1'
     *
     * @var string
     */
    private $memcacheUserPrefix = '_mem_user';

    /**
     * Memcache key timeout (1 day)
     */
    const MEMCACHE_CODE_TIMEOUT = 50400;

    /**
     * Cookie timeout for remember (1 year)
     */
    const COOKIE_LONG_DATE = 31536000;

    /**
     * Cookie actually timeout  (3 day)
     */
    const COOKIE_SHORT_DATE = 151200;

    /**
     * @param  Configuration $config
     * @throws MemcacheNotFoundException
     */
    public function __construct(Configuration $config){
        if(!class_exists('Memcache'))
            throw new MemcacheNotFoundException();

        // set hash
        $this->hashKey        = $config->getHashKey();
        $this->crossDomain    = $config->getCrossDomain();
        $this->crossDomainUrl = $config->getCrossDomainUrl();
        $this->ipChecker      = $config->isIpCheckerEnabled();
        $this->model          = $config->getModel();
    }

    /**
     * @param $email
     * @param $password
     * @param bool $rememberMe
     * @param array $alternativeParams
     * @return bool
     */
    public function login($email, $password, $rememberMe = true, $alternativeParams = []){
        // get model and find user
        $userModel = call_user_func([$this->model, 'instance']);

        $where = ['email' => $email];

        if (!empty($alternativeParams)) {
            $where = array_merge($where, $alternativeParams);
        }

        $user = $userModel->where($where)->runOnce();

        if(is_null($user))
            return false;

{'fraction_non_alphanumeric': 0.12531370252635102, 'fraction_numerical': 0.008365400702693659, 'mean_word_length': 2.234848484848485, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 39, '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': '2750774', 'n_tokens_mistral': 1826, 'n_tokens_neox': 1743, 'n_words': 425}