mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Rework tests structure. Upgrade codeception to 2.5.3. Merge params configuration into app configuration.
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace api\modules\authserver;
|
||||
|
||||
use Yii;
|
||||
use yii\base\BootstrapInterface;
|
||||
use yii\base\InvalidConfigException;
|
||||
use yii\web\NotFoundHttpException;
|
||||
|
||||
class Module extends \yii\base\Module implements BootstrapInterface {
|
||||
@ -12,18 +13,6 @@ class Module extends \yii\base\Module implements BootstrapInterface {
|
||||
|
||||
public $defaultRoute = 'index';
|
||||
|
||||
/**
|
||||
* @var string базовый домен, запросы на который этот модуль должен обрабатывать
|
||||
*/
|
||||
public $host = 'authserver.ely.by';
|
||||
|
||||
public function init() {
|
||||
parent::init();
|
||||
if ($this->host === null) {
|
||||
throw new InvalidConfigException('base domain must be specified');
|
||||
}
|
||||
}
|
||||
|
||||
public function beforeAction($action) {
|
||||
if (!parent::beforeAction($action)) {
|
||||
return false;
|
||||
@ -35,11 +24,12 @@ class Module extends \yii\base\Module implements BootstrapInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \yii\base\Application $app the application currently running
|
||||
* @param \yii\base\Application $app
|
||||
*/
|
||||
public function bootstrap($app) {
|
||||
$legacyHost = $app->params['authserverHost'];
|
||||
$app->getUrlManager()->addRules([
|
||||
"//$this->host/$this->id/auth/<action>" => "$this->id/authentication/<action>",
|
||||
"//{$legacyHost}/authserver/auth/<action>" => "{$this->id}/authentication/<action>",
|
||||
], false);
|
||||
}
|
||||
|
||||
@ -59,7 +49,7 @@ class Module extends \yii\base\Module implements BootstrapInterface {
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
protected function checkHost() {
|
||||
if (parse_url(Yii::$app->request->getHostInfo(), PHP_URL_HOST) !== $this->host) {
|
||||
if (parse_url(Yii::$app->request->getHostInfo(), PHP_URL_HOST) !== Yii::$app->params['authserverHost']) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user