<commit_before><?php
namespace thinker_g\UserAuth\models;

use Yii;
use yii\base\NotSupportedException;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
use yii\web\IdentityInterface;
use yii\db\Expression as DbExpression;
use yii\db\ActiveQuery;

/**
 * User model
 *
 * @property integer $id
 * @property string $username
 * @property string $primary_email
 * @property string $password_hash
 * @property integer $status
 * @property string $auth_key
 * @property string $password_reset_token
 * @property string $password Virtual attribute, does't exist in db table.
 * @property integer $created_at
 * @property integer $updated_at
 * @property array $userExtAccounts
 *
 */
class User extends ActiveRecord implements IdentityInterface
{
    /**
     * User is deleted.
     * For further usage, status code 0-9 is preserved for unavailable status.
     * @var int
     */
    const STATUS_DELETED = 0;

    /**
     * User is registered, but still not finish the onboarding procedure yet.
     * The onboarding procedure might be something like email confirmation, initial email stream, etc.
     * For further usage, status code 10-19 is preserved for unavailable status.
     * @var int
     */
    const STATUS_PENDING = 10;

    /**
     * User is active. Means normal users who completed all their onboarding procedure.
     * For further usage, status code 20-29 is preserved for unavailable status.
     * @var int
     */
    const STATUS_ACTIVE = 20;

    /**
     * Attribute to temporarily store password.
     * This attribute should always be "null" unless an operation is changing password.
     * Whenever this attributes has value, the password_hash will be updated immediately by calling `setPassword()`.
     * @var string
     */
    private $_pswd;

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%user}}';
    }

    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            TimestampBehavior::className() => [
                'class' => TimestampBehavior::className(),
                'updatedAtAttribute' => 'last_login_at',
                'value' => new DbExpression('CURRENT_TIMESTAMP')
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['username', 'primary_email'], 'unique'],
            [['password', 'created_at', 'last_login_at'], 'safe'],
            [['status'], 'default', 'value' => self::STATUS_PENDING],
            [['status'], 'in', 'range' => [
                self::STATUS_PENDING,
                self::STATUS_ACTIVE,<commit_msg>Remove TSBehavior. Last login TS will be updated by event handler on yii\web\User.<commit_after><?php
namespace thinker_g\UserAuth\models;

use Yii;
use yii\base\NotSupportedException;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
use yii\web\IdentityInterface;
use yii\db\Expression as DbExpression;
use yii\db\ActiveQuery;

/**
 * User model
 *
 * @property integer $id
 * @property string $username
 * @property string $primary_email
 * @property string $password_hash
 * @property integer $status
 * @property string $auth_key
 * @property string $password_reset_token
 * @property string $password Virtual attribute, does't exist in db table.
 * @property integer $created_at
 * @property integer $updated_at
 * @property array $userExtAccounts
 *
 */
class User extends ActiveRecord implements IdentityInterface
{
    /**
     * User is deleted.
     * For further usage, status code 0-9 is preserved for unavailable status.
     * @var int
     */
    const STATUS_DELETED = 0;

    /**
     * User is registered, but still not finish the onboarding procedure yet.
     * The onboarding procedure might be something like email confirmation, initial email stream, etc.
     * For further usage, status code 10-19 is preserved for unavailable status.
     * @var int
     */
    const STATUS_PENDING = 10;

    /**
     * User is active. Means normal users who completed all their onboarding procedure.
     * For further usage, status code 20-29 is preserved for unavailable status.
     * @var int
     */
    const STATUS_ACTIVE = 20;

    /**
     * Attribute to temporarily store password.
     * This attribute should always be "null" unless an operation is changing password.
     * Whenever this attributes has value, the password_hash will be updated immediately by calling `setPassword()`.
     * @var string
     */
    private $_pswd;

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%user}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['username', 'primary_email'], 'unique'],
            [['password', 'created_at', 'last_login_at'], 'safe'],
            [['status'], 'default', 'value' => self::STATUS_PENDING],
            [['status'], 'in', 'range' => [
                self::STATUS_PENDING,
                self::STATUS_ACTIVE,
{'fraction_non_alphanumeric': 0.10551368504561681, 'fraction_numerical': 0.005950019833399445, 'mean_word_length': 2.6972140762463344, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '6134123', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1359, 'n_words': 458}