Merge branch 'develop' of github.com:humhub/humhub into develop

This commit is contained in:
Lucas Bartholemy 2022-10-05 14:14:55 +02:00
commit ba96a15b2f
4 changed files with 42 additions and 2 deletions

View File

@ -7,4 +7,4 @@ HumHub Changelog
- Enh #5841: Possibility to show Members/Followers as list from Space about page
- Enh #5850: Display all levels by default on info logging page
- Enh #5864: Use Base URL from general settings for all generated absolute URLs
- Enh #5872: Invalidate active sessions after password changing

View File

@ -0,0 +1,25 @@
<?php
use humhub\components\Migration;
/**
* Class m220919_104234_auth_key
*/
class m220919_104234_auth_key extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->safeAddColumn('user', 'auth_key', $this->string(32)->null());
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->safeDropColumn('user', 'auth_key');
}
}

View File

@ -24,6 +24,8 @@ use humhub\modules\user\components\CheckPasswordValidator;
* @property string $password
* @property string $salt
* @property string $created_at
*
* @property-read User $user
*/
class Password extends ActiveRecord
{
@ -185,6 +187,7 @@ class Password extends ActiveRecord
$this->salt = UUID::v4();
$this->algorithm = $this->defaultAlgorithm;
$this->password = $this->hashPassword($newPassword);
$this->user->auth_key = Yii::$app->security->generateRandomString(32);
}
public function getUser()
@ -213,4 +216,15 @@ class Password extends ActiveRecord
}
}
public function afterSave($insert, $changedAttributes)
{
parent::afterSave($insert, $changedAttributes);
if ($this->user->isAttributeChanged('auth_key') &&
$this->user->save() &&
$this->user->isCurrentUser()) {
Yii::$app->user->switchIdentity($this->user);
}
}
}

View File

@ -56,6 +56,7 @@ use yii\web\IdentityInterface;
* @property integer $updated_by
* @property string $last_login
* @property string $authclient_id
* @property string $auth_key
* @property integer $visibility
* @property integer $contentcontainer_id
* @property Profile $profile
@ -350,7 +351,7 @@ class User extends ContentContainerActiveRecord implements IdentityInterface, Se
public function getAuthKey()
{
return $this->guid;
return $this->auth_key ?: $this->guid;
}
public function validateAuthKey($authKey)