getAttribute('id'); } /** @inheritdoc */ public function getAuthKey() { return $this->getAttribute('auth_key'); } /** @inheritdoc */ public function behaviors() { return [ TimestampBehavior::className(), ]; } /** @inheritdoc */ public function validateAuthKey($authKey) { return $this->getAttribute('auth_key') == $authKey; } /** * Resets password. * * @param string $password * @return bool */ public function resetPassword($password) { return (bool) $this->updateAttributes(['password_hash' => Password::hash($password)]); } /** @inheritdoc */ public function beforeSave($insert) { if ($insert) { $this->setAttribute('auth_key', Yii::$app->security->generateRandomString()); } if (!empty($this->password)) { $this->setAttribute('password_hash', Password::hash($this->password)); $this->setAttribute('password', $this->password); } return parent::beforeSave($insert); } /** @inheritdoc */ public static function findIdentity($id) { return static::findOne($id); } /** @inheritdoc */ public static function findIdentityByAccessToken($token, $type = null) { throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.'); } public function getProfile() { return $this->hasOne(SysUserProfileModel::className(), ['sys_user_id' => 'id']); } }