From 47ecad75130e978dbee3afd13f359bda02013df9 Mon Sep 17 00:00:00 2001 From: Basil Suter Date: Tue, 8 Sep 2020 10:44:09 +0000 Subject: [PATCH 1/2] change behavior order (https://www.yiiframework.com/doc/guide/2.0/en/rest-controllers#cors) --- core/traits/RestBehaviorsTrait.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/traits/RestBehaviorsTrait.php b/core/traits/RestBehaviorsTrait.php index 891883021..378535883 100644 --- a/core/traits/RestBehaviorsTrait.php +++ b/core/traits/RestBehaviorsTrait.php @@ -121,9 +121,14 @@ public function behaviors() { $behaviors = parent::behaviors(); - if (!$this->getUserAuthClass()) { - unset($behaviors['authenticator']); - } else { + if ($this->enableCors) { + $behaviors['cors'] = Yii::$app->corsConfig; + } + + unset($behaviors['authenticator']); + + if ($this->getUserAuthClass()) { + // change to admin user auth class $behaviors['authenticator'] = [ 'class' => CompositeAuth::class, @@ -136,10 +141,6 @@ public function behaviors() $behaviors['authenticator']['except'] = ['options']; } } - - if ($this->enableCors) { - $behaviors['cors'] = Yii::$app->corsConfig; - } $behaviors['contentNegotiator'] = [ 'class' => ContentNegotiator::class, From f5f880b1da7efa757362e6f18a48a4e8c0605189 Mon Sep 17 00:00:00 2001 From: Basil Suter Date: Tue, 8 Sep 2020 11:59:36 +0000 Subject: [PATCH 2/2] add changelog --- core/CHANGELOG.md | 4 ++++ core/base/Boot.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index f5219a3bc..8927b2c64 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). In order to read more about upgrading and BC breaks have a look at the [UPGRADE Document](UPGRADE.md). +## 1.7.1 + ++ [#2049](https://github.com/luyadev/luya/pull/2049) Change the behaviors attaching order to follow [Yii CORS guide](https://www.yiiframework.com/doc/guide/2.0/en/rest-controllers#cors). + ## 1.7.0 (26. August 2020) + [#2045](https://github.com/luyadev/luya/pull/2045) Provide application methods to retrieve menu and asset data from all admin modules. diff --git a/core/base/Boot.php b/core/base/Boot.php index 262d0771b..b954a64dc 100644 --- a/core/base/Boot.php +++ b/core/base/Boot.php @@ -24,7 +24,7 @@ abstract class Boot /** * @var string The current LUYA version (see: https://github.com/luyadev/luya/blob/master/core/CHANGELOG.md) */ - const VERSION = '1.7.0'; + const VERSION = '1.7.1'; /** * @var string The path to the config file, which returns an array containing you configuration.