Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

user random string #759

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
In order to read more about upgrading and BC breaks have a look at the [UPGRADE Document](UPGRADE.md).

## 5.0.3 ()

+ [#759](https://github.com/luyadev/luya-module-admin/pull/759) Prevent `Bcrypt password must not contain null character` errors by using generateRandomString for auth_key encryption.

## 5.0.2 (28. March 2024)

+ [#758](https://github.com/luyadev/luya-module-admin/pull/758) Enhanced the functionality to reorganize folders within the folder hierarchy, allowing for movement to the root or placement into a different subfolder.
Expand Down
8 changes: 5 additions & 3 deletions src/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -589,14 +589,16 @@ public function getId()
*/
public function getAuthKey()
{
// find user agent, if empty disable auto login
$userAgent = Yii::$app->request->userAgent;

// no user agent, dissable auto login
if (empty($userAgent)) {
return false;
}

$checksum = UserDevice::generateUserAgentChecksum($userAgent);
if (empty($checksum)) {
return false;
}

$model = UserDevice::find()->where(['user_id' => $this->id, 'user_agent_checksum' => $checksum])->one();

Expand All @@ -610,7 +612,7 @@ public function getAuthKey()
$model->user_id = $this->id;
$model->user_agent = $userAgent;
$model->user_agent_checksum = $checksum;
$model->auth_key = Yii::$app->security->generatePasswordHash(Yii::$app->security->generateRandomKey() . $checksum);
$model->auth_key = Yii::$app->security->generatePasswordHash(Yii::$app->security->generateRandomString() . $checksum);

if ($model->save()) {
return $model->auth_key;
Expand Down
Loading