<commit_before>
namespace Ice\Auth\Driver\Model;

use Ice\Auth\Driver\Model\Roles;
use Ice\Mvc\Model;

/**
 * Model Users.
 *
 * @package     Ice/Auth
 * @category    Model
 * @author      I<NAME>
 * @copyright   (c) 2014-2018 Ice Team
 * @license     http://iceframework.org/license
 */
class Users extends Model
{

    /**
     * Initialize user's relations.
     *
     * @return void
     */
    public function initialize()
    {
        this->hasMany(this->getIdKey(), "Ice\\Auth\\Driver\\Model\\Users\\Tokens", "user_id", [
            "alias": "Tokens"
        ]);

        this->hasMany(this->getIdKey(), "Ice\\Auth\\Driver\\Model\\Roles\\Users", "user_id", [
            "alias": "Roles"
        ]);

        this->hasOne(this->getIdKey(), "Ice\\Auth\\Driver\\Model\\Users\\Social", "user_id", [
            "alias": "Social"
        ]);
    }

    /**
     * Complete the login for a user by incrementing the logins and saving login timestamp.
     *
     * @return object this
     */
    public function completeLogin()
    {
        // Update the number of logins and last login time
        let this->{"logins"} = this->get("logins") + 1,
            this->{"lastlogin"} = time();

        this->update();

        return this;
    }

    /**
     * Get user's role.
     *
     * @param string name Role name to get
     * @return mixed
     */
    public function getRole(string name = "login")
    {
        var role, roles;

        let role = <Roles> Roles::findOne(["name": name]);

        if !role {
            // Role does not exist
            return null;<commit_msg>Auth, make model classes in users configable<commit_after>
namespace Ice\Auth\Driver\Model;

use Ice\Mvc\Model;

/**
 * Model Users.
 *
 * @package     Ice/Auth
 * @category    Model
 * @author      Ice Team
 * @copyright   (c) 2014-2018 Ice Team
 * @license     http://iceframework.org/license
 */
class Users extends Model
{
    /**
     * Role class name.
     */
    protected $roleClass = "Ice\\Auth\\Driver\\Model\\Roles";

    /**
     * Token class name.
     */
    protected $tokenClass = "Ice\\Auth\\Driver\\Model\\Users\\Tokens";

    /**
     * User class name.
     */
    protected $userClass = "Ice\\Auth\\Driver\\Model\\Roles\\Users";

    /**
     * Social class name.
     */
    protected $tokenClass = "Ice\\Auth\\Driver\\Model\\Users\\Social";

    /**
     * Initialize user's relations.
     *
     * @return void
     */
    public function initialize()
    {
        var idKey;
        let idKey = this->getIdKey();

        this->hasMany(idKey, this->tokenClass, "user_id", ["alias": "Tokens"]);

        this->hasMany(idKey, this->userClass, "user_id", ["alias": "Roles"]);

        this->hasOne(idKey, this->socialClass, "user_id", ["alias": "Social"]);
    }

    /**
     * Complete the login for a user by incrementing the logins and saving login timestamp.
     *
     * @return object this
     */
    public function completeLogin()
    {
        // Update the number of logins and last login time
        let this->{"logins"} = this->get("logins") + 1,
            this->{"lastlogin"} = time();

        this->update();

        return this;
    }

    /**
     * Get user's role.
     *
     * @param string name Role name to get
     * @return mixed
     */
    public function getRole(string name = "login")
    {
        var role, roles;

        let role = {this->roleClass}::findOne(["name": name]);

        if !role {
            // Role does not exist
            return null;
{'fraction_non_alphanumeric': 0.15277382645803697, 'fraction_numerical': 0.005120910384068279, 'mean_word_length': 1.9081885856079404, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 27, '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': '3689814', 'n_tokens_mistral': 1090, 'n_tokens_neox': 1045, 'n_words': 272}