<commit_before><?php defined('SYSPATH') or die('No direct access allowed.');
/**
 * Default auth user
 *
 * @package    Kohana/Auth
 * @author     creatoro
 * @copyright  (c) 2011 creatoro
 * @license    http://creativecommons.org/licenses/by-sa/3.0/legalcode
 */
class Model_Auth_User extends Jelly_Model {

	public static function initialize(Jelly_Meta $meta)
    {
        // The table the model is attached to
        $meta->table('users');

        // Fields defined by the model
        $meta->fields(array(
            'id' => Jelly::field('primary'),
            'email' => Jelly::field('email', array(
				'label' => 'email address',
				'rules' => array(
					array('not_empty'),
					array('min_length', array(':value', 4)),
					array('max_length', array(':value', 127)),
				),
				'unique' => TRUE,
			)),
            'username' => Jelly::field('string', array(
				'label' => 'username',
				'rules' => array(
					array('not_empty'),
					array('min_length', array(':value', 4)),
					array('max_length', array(':value', 32)),
					array('regex', array(':value', '/^[-\pL\pN_.]++$/uD')),
				),
				'unique' => TRUE,
			)),
			'password' => Jelly::field('password', array(
				'label' => 'password',
				'rules' => array(
					array('not_empty'),
					array('min_length', array(':value', 8)),
					array('matches', array(':validation', ':field', 'password_confirm')),
				),
				'hash_with' => array(Auth::instance(), 'hash'),
			)),
			'password_confirm' => Jelly::field('password', array(
				'in_db' => FALSE,
			)),
			'logins' => Jelly::field('integer', array(
				'convert_empty' => TRUE,
				'empty_value' => 0,
			)),
			'last_login' => Jelly::field('timestamp'),

            // Relationships to other models
            'user_tokens' => Jelly::field('hasmany', array(
				'foreign' => 'user_token',
			)),
            'roles' => Jelly::field('manytomany'),
        ));
    }

	/**
	 * Complete the login for a user by incrementing the logins and saving login timestamp
	 *
	 * @return void
	 */
	public function complete_login()
	{
		if ($this->_loaded)
		{
			// Update the number of logins
			$this->logins = $this->logins + 1;

			// Set the last login date<commit_msg>Default value for logins in user model.<commit_after><?php defined('SYSPATH') or die('No direct access allowed.');
/**
 * Default auth user
 *
 * @package    Kohana/Auth
 * @author     creatoro
 * @copyright  (c) 2011 creatoro
 * @license    http://creativecommons.org/licenses/by-sa/3.0/legalcode
 */
class Model_Auth_User extends Jelly_Model {

	public static function initialize(Jelly_Meta $meta)
    {
        // The table the model is attached to
        $meta->table('users');

        // Fields defined by the model
        $meta->fields(array(
            'id' => Jelly::field('primary'),
            'email' => Jelly::field('email', array(
				'label' => 'email address',
				'rules' => array(
					array('not_empty'),
					array('min_length', array(':value', 4)),
					array('max_length', array(':value', 127)),
				),
				'unique' => TRUE,
			)),
            'username' => Jelly::field('string', array(
				'label' => 'username',
				'rules' => array(
					array('not_empty'),
					array('min_length', array(':value', 4)),
					array('max_length', array(':value', 32)),
					array('regex', array(':value', '/^[-\pL\pN_.]++$/uD')),
				),
				'unique' => TRUE,
			)),
			'password' => Jelly::field('password', array(
				'label' => 'password',
				'rules' => array(
					array('not_empty'),
					array('min_length', array(':value', 8)),
					array('matches', array(':validation', ':field', 'password_confirm')),
				),
				'hash_with' => array(Auth::instance(), 'hash'),
			)),
			'password_confirm' => Jelly::field('password', array(
				'in_db' => FALSE,
			)),
			'logins' => Jelly::field('integer', array(
				'default' => 0,
				'convert_empty' => TRUE,
				'empty_value' => 0,
			)),
			'last_login' => Jelly::field('timestamp'),

            // Relationships to other models
            'user_tokens' => Jelly::field('hasmany', array(
				'foreign' => 'user_token',
			)),
            'roles' => Jelly::field('manytomany'),
        ));
    }

	/**
	 * Complete the login for a user by incrementing the logins and saving login timestamp
	 *
	 * @return void
	 */
	public function complete_login()
	{
		if ($this->_loaded)
		{
			// Update the number of logins
			$this->logins = $this->logins + 1;

			// Set the last login date
{'fraction_non_alphanumeric': 0.19315623592976136, 'fraction_numerical': 0.007429085997298514, 'mean_word_length': 2.900790166812994, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 58, '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': '635266', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1404, 'n_words': 323}