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

Fix user component initialization #126

Merged
merged 1 commit into from
May 26, 2023
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
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