Skip to content

Commit

Permalink
Fix visibility of the method Controller::getAccessRules()
Browse files Browse the repository at this point in the history
  • Loading branch information
yurabakhtin committed Oct 25, 2023
1 parent 623ebaa commit 1c41b27
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 50 deletions.
100 changes: 50 additions & 50 deletions controllers/ConfigController.php
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
<?php

/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2020 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*
*/

namespace humhub\modules\twofa\controllers;

use humhub\modules\admin\permissions\ManageModules;
use humhub\modules\admin\components\Controller;
use humhub\modules\twofa\helpers\TwofaHelper;
use humhub\modules\twofa\models\Config;
use Yii;

class ConfigController extends Controller
{
/**
* @inheritdoc
*/
public function getAccessRules()
{
return [['permissions' => ManageModules::class]];
}

/**
* Configuration action for system admins.
*/
public function actionIndex()
{
$model = new Config();

if ($model->load(Yii::$app->request->post()) && $model->save()) {
$this->view->saved();
}

$ip = Yii::$app->request->userIP;
if ($ip !== Yii::$app->request->remoteIP) {
$ip .= ', ' . Yii::$app->request->remoteIP;
}

return $this->render('module', [
'model' => $model,
'defaultDriverName' => TwofaHelper::getDriverByClassName($model->module->defaultDriver)->name,
'ip' => $ip,
]);
}
}
<?php

/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2020 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*
*/

namespace humhub\modules\twofa\controllers;

use humhub\modules\admin\permissions\ManageModules;
use humhub\modules\admin\components\Controller;
use humhub\modules\twofa\helpers\TwofaHelper;
use humhub\modules\twofa\models\Config;
use Yii;

class ConfigController extends Controller
{
/**
* @inheritdoc
*/
protected function getAccessRules()
{
return [['permissions' => ManageModules::class]];
}

/**
* Configuration action for system admins.
*/
public function actionIndex()
{
$model = new Config();

if ($model->load(Yii::$app->request->post()) && $model->save()) {
$this->view->saved();
}

$ip = Yii::$app->request->userIP;
if ($ip !== Yii::$app->request->remoteIP) {
$ip .= ', ' . Yii::$app->request->remoteIP;
}

return $this->render('module', [
'model' => $model,
'defaultDriverName' => TwofaHelper::getDriverByClassName($model->module->defaultDriver)->name,
'ip' => $ip,
]);
}
}
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
1.1.4 (Unreleased)
----------------------
- Enh #58: Tests for `next` version
- Fix #59: Fix visibility of the method `Controller::getAccessRules()`

1.1.3 (June 8, 2023)
--------------------
Expand Down

0 comments on commit 1c41b27

Please sign in to comment.