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

change behavior order #2049

Merged
merged 2 commits into from
Sep 8, 2020
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
4 changes: 4 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion core/base/Boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 8 additions & 7 deletions core/traits/RestBehaviorsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -136,10 +141,6 @@ public function behaviors()
$behaviors['authenticator']['except'] = ['options'];
}
}

if ($this->enableCors) {
$behaviors['cors'] = Yii::$app->corsConfig;
}

$behaviors['contentNegotiator'] = [
'class' => ContentNegotiator::class,
Expand Down