Skip to content

Commit

Permalink
Merge pull request #126 from humhub/fix/module-user-init
Browse files Browse the repository at this point in the history
Fix user component initialization
  • Loading branch information
luke- committed May 26, 2023
2 parents 7aff3cb + 3c3496a commit 4d45516
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
14 changes: 1 addition & 13 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
namespace humhub\modules\rest;

use humhub\components\bootstrap\ModuleAutoLoader;
use \humhub\components\Module as BaseModule;
use humhub\modules\user\models\User as UserModel;
use humhub\modules\rest\components\User as UserComponent;
use humhub\components\Module as BaseModule;
use Yii;
use yii\helpers\Url;

Expand All @@ -32,16 +30,6 @@ class Module extends BaseModule
*/
public $resourcesPath = 'resources';

public function init()
{
Yii::$app->set('user', [
'class' => UserComponent::class,
'identityClass' => UserModel::class,
]);

parent::init();
}

/**
* @inheritdoc
*/
Expand Down
21 changes: 13 additions & 8 deletions components/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@

namespace humhub\modules\rest\components;

use humhub\components\access\ControllerAccess;
use humhub\components\Controller;
use humhub\modules\content\models\Content;
use humhub\modules\rest\components\auth\ImpersonateAuth;
use humhub\modules\rest\components\User as UserComponent;
use humhub\modules\rest\components\auth\JwtAuth;
use humhub\modules\rest\controllers\auth\AuthController;
use humhub\modules\rest\models\ConfigureForm;
use humhub\modules\user\models\User;
use Yii;
use yii\data\Pagination;
use yii\db\ActiveQuery;
Expand All @@ -17,14 +25,6 @@
use yii\filters\auth\QueryParamAuth;
use yii\helpers\ArrayHelper;
use yii\web\JsonParser;
use Firebase\JWT\JWT;
use humhub\components\access\ControllerAccess;
use humhub\components\Controller;
use humhub\modules\content\models\Content;
use humhub\modules\rest\components\auth\JwtAuth;
use humhub\modules\rest\controllers\auth\AuthController;
use humhub\modules\rest\models\ConfigureForm;
use humhub\modules\user\models\User;

/**
* Class BaseController
Expand Down Expand Up @@ -89,6 +89,11 @@ public function behaviors()
*/
public function beforeAction($action)
{
Yii::$app->set('user', [
'class' => UserComponent::class,
'identityClass' => User::class,
]);

Yii::$app->response->format = 'json';

Yii::$app->request->setBodyParams(null);
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

0.9.1 (Unreleased)
--------------------
- Fix #126: Fix user component initialization

0.9.0 (May 17, 2023)
--------------------
- Fix #110: Fix PHP Error in UserDefinition
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"keywords": [
"api", "rest"
],
"version": "0.9.0",
"version": "0.9.1",
"homepage": "https://github.com/humhub/rest",
"humhub": {
"minVersion": "1.14"
Expand Down

0 comments on commit 4d45516

Please sign in to comment.