Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
newShopBack
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
newshop
newShopBack
Commits
ea23f035
Commit
ea23f035
authored
Dec 11, 2019
by
孙磊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码格式化
Signed-off-by:
sunlei
<
sunlei@romens.cn
>
parent
c38d4418
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
15 deletions
+19
-15
BaseController.php
backend/controllers/v1/BaseController.php
+19
-15
No files found.
backend/controllers/v1/BaseController.php
View file @
ea23f035
<?php
namespace
backend\controllers\v1
;
use
Yii
;
...
...
@@ -9,6 +10,7 @@ use yii\filters\auth\HttpBearerAuth;
use
yii\filters\auth\QueryParamAuth
;
use
yii\filters\Cors
;
use
backend\components\v1\authorizationFilter
;
/**
* Base controller
* 基类
...
...
@@ -64,30 +66,32 @@ class BaseController extends ActiveController
$behaviors
=
parent
::
behaviors
();
// 跨域请求配置
$behaviors
=
array_merge
(
[
'cors'
=>
[
'class'
=>
Cors
::
className
(),
[
'cors'
=>
[
'Origin'
=>
[
'http://localhost:8000'
,
'http://192.168.188.207:8000'
],
'Access-Control-Request-Method'
=>
[
'GET'
,
'POST'
,
'PUT'
,
'PATCH'
,
'DELETE'
,
'HEAD'
,
'OPTIONS'
],
'Access-Control-Request-Headers'
=>
[
'*'
],
'Access-Control-Allow-Credentials'
=>
true
,
'Access-Control-Max-Age'
=>
3600
,
'Access-Control-Expose-Headers'
=>
[
'*'
],
],
]
],
$behaviors
);
'class'
=>
Cors
::
className
(),
'cors'
=>
[
'Origin'
=>
[
'http://localhost:8000'
,
'http://192.168.188.207:8000'
],
'Access-Control-Request-Method'
=>
[
'GET'
,
'POST'
,
'PUT'
,
'PATCH'
,
'DELETE'
,
'HEAD'
,
'OPTIONS'
],
'Access-Control-Request-Headers'
=>
[
'*'
],
'Access-Control-Allow-Credentials'
=>
true
,
'Access-Control-Max-Age'
=>
3600
,
'Access-Control-Expose-Headers'
=>
[
'*'
],
],
]
],
$behaviors
);
// 格式化输出请求
$behaviors
[
'contentNegotiator'
][
'formats'
][
'text/html'
]
=
Response
::
FORMAT_JSON
;
// 认证
$behaviors
[
'HttpBearerAuth'
]
=
[
$behaviors
[
'HttpBearerAuth'
]
=
[
'class'
=>
HttpBearerAuth
::
className
(),
'optional'
=>
[
'login'
],
];
// 授权
$behaviors
[
'authorizationFilter'
]
=
[
$behaviors
[
'authorizationFilter'
]
=
[
'class'
=>
authorizationFilter
::
className
(),
'optional'
=>
[
'login'
],
//过滤不需要验证的action
'optional'
=>
[
'login'
],
//过滤不需要验证的action
];
return
$behaviors
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment