Skip to content

Commit

Permalink
Create random access token when creating new user in order to prevent…
Browse files Browse the repository at this point in the history
… unique column exception #76
  • Loading branch information
nadar committed Mar 28, 2018
1 parent 6167d7e commit 444d7ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion src/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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);
}
}
});
}
Expand Down

0 comments on commit 444d7ab

Please sign in to comment.