diff --git a/CHANGELOG.md b/CHANGELOG.md index a6dcb44ded..e55b4941c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. This project make usage of the [Yii Versioning Strategy](https://github.com/yiisoft/yii2/blob/master/docs/internals/versions.md). In order to read more about upgrading and BC breaks have a look at the [UPGRADE Document](UPGRADE.md). +## 1.1.1 (in progress) + +### Fixed + ++ [#76](https://github.com/luyadev/luya-module-admin/issues/76) Create random access token when creating new user in order to prevent unique column exception. + ## 1.1.0 (26. March 2018) This release contains new migrations and requires to run the `migrate` command after updating. diff --git a/src/models/User.php b/src/models/User.php index eaf5cb0aa8..5348e7ebb7 100644 --- a/src/models/User.php +++ b/src/models/User.php @@ -13,7 +13,6 @@ use luya\admin\aws\UserHistorySummaryActiveWindow; use luya\admin\models\NgrestLog; use luya\admin\base\RestActiveController; -use yii\web\ForbiddenHttpException; use yii\base\InvalidArgumentException; /** @@ -59,6 +58,10 @@ public function init() $this->on(self::EVENT_AFTER_VALIDATE, function() { if ($this->scenario == RestActiveController::SCENARIO_RESTCREATE) { $this->encodePassword(); + + if ($this->isNewRecord) { + $this->auth_token = Yii::$app->security->hashData(Yii::$app->security->generateRandomString(), $this->password_salt); + } } }); }