Commit 142782fa authored by 郭勇志's avatar 郭勇志

test

parent d29da5d2
<?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
......@@ -57,10 +57,10 @@ class BaseController extends ActiveController
'optional' => ['login'],
];
// 授权
$behaviors['authorizationFilter']=[
'class' => authorizationFilter::className(),
'optional' => [],//过滤不需要验证的action
];
// $behaviors['authorizationFilter']=[
// 'class' => authorizationFilter::className(),
// 'optional' => [],//过滤不需要验证的action
// ];
return $behaviors;
}
}
......@@ -40,14 +40,6 @@ class BranchController extends BaseController
public function actionTest()
{
$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;
}
......
<?php
namespace app\models\v1\user;
namespace backend\models\v1\user;
use Yii;
use yii\base\Model;
......@@ -56,6 +56,7 @@ class LoginForm extends Model
if ($this->validate()) {
$accessToken=$this->_shopRbacUser->generateAccessToken();
// 生成的access_token保存一份到mysql和redis中
var_dump($this->_shopRbacUser);exit;
$this->_shopRbacUser->save();
return $accessToken;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment