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
142782fa
Commit
142782fa
authored
Nov 05, 2019
by
郭勇志
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
d29da5d2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
13 deletions
+48
-13
authorizationFilter.php
backend/components/v1/authorizationFilter.php
+42
-0
BaseController.php
backend/controllers/v1/BaseController.php
+4
-4
BranchController.php
backend/controllers/v1/shop/branch/BranchController.php
+0
-8
LoginForm.php
backend/models/v1/user/LoginForm.php
+2
-1
No files found.
backend/components/v1/authorizationFilter.php
0 → 100644
View file @
142782fa
<?php
namespace
backend\components\v1
;
use
Yii
;
use
yii\base\ActionFilter
;
use
yii\helpers\StringHelper
;
class
authorizationFilter
extends
ActionFilter
{
public
$optional
;
public
function
beforeAction
(
$action
)
{
if
(
$this
->
isOptional
(
$action
))
{
return
true
;
}
// Yii::$app->user->identity;
}
/**
* Checks, whether authentication is optional for the given action.
*
* @param Action $action action to be checked.
* @return bool whether authentication is optional or not.
* @see optional
* @since 2.0.7
*/
protected
function
isOptional
(
$action
)
{
$id
=
$this
->
getActionId
(
$action
);
foreach
(
$this
->
optional
as
$pattern
)
{
if
(
StringHelper
::
matchWildcard
(
$pattern
,
$id
))
{
return
true
;
}
}
return
false
;
}
}
\ No newline at end of file
backend/controllers/v1/BaseController.php
View file @
142782fa
...
@@ -57,10 +57,10 @@ class BaseController extends ActiveController
...
@@ -57,10 +57,10 @@ class BaseController extends ActiveController
'optional'
=>
[
'login'
],
'optional'
=>
[
'login'
],
];
];
// 授权
// 授权
$behaviors
[
'authorizationFilter'
]
=
[
//
$behaviors['authorizationFilter']=[
'class'
=>
authorizationFilter
::
className
(),
//
'class' => authorizationFilter::className(),
'optional'
=>
[],
//过滤不需要验证的action
//
'optional' => [],//过滤不需要验证的action
];
//
];
return
$behaviors
;
return
$behaviors
;
}
}
}
}
backend/controllers/v1/shop/branch/BranchController.php
View file @
142782fa
...
@@ -40,14 +40,6 @@ class BranchController extends BaseController
...
@@ -40,14 +40,6 @@ class BranchController extends BaseController
public
function
actionTest
()
public
function
actionTest
()
{
{
$get
=
Yii
::
$app
->
request
->
get
();
$get
=
Yii
::
$app
->
request
->
get
();
// $key = 'username';
// $redis = Yii::$app->redis;
// if ($val = $redis->get($key)) {
// Yii::trace('redis',$val );
// } else {
// $redis->set($key, 'test');
// // $redis->expire($key, 5);
// }
return
$get
;
return
$get
;
}
}
...
...
backend/models/v1/user/LoginForm.php
View file @
142782fa
<?php
<?php
namespace
app
\models\v1\user
;
namespace
backend
\models\v1\user
;
use
Yii
;
use
Yii
;
use
yii\base\Model
;
use
yii\base\Model
;
...
@@ -56,6 +56,7 @@ class LoginForm extends Model
...
@@ -56,6 +56,7 @@ class LoginForm extends Model
if
(
$this
->
validate
())
{
if
(
$this
->
validate
())
{
$accessToken
=
$this
->
_shopRbacUser
->
generateAccessToken
();
$accessToken
=
$this
->
_shopRbacUser
->
generateAccessToken
();
// 生成的access_token保存一份到mysql和redis中
// 生成的access_token保存一份到mysql和redis中
var_dump
(
$this
->
_shopRbacUser
);
exit
;
$this
->
_shopRbacUser
->
save
();
$this
->
_shopRbacUser
->
save
();
return
$accessToken
;
return
$accessToken
;
}
}
...
...
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