fixed
This commit is contained in:
63
front/application/common/behavior/LoginBehavior.php
Normal file
63
front/application/common/behavior/LoginBehavior.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/*
|
||||
* description:
|
||||
* author:wh
|
||||
* email:
|
||||
* createTime:{2023/12/5} {15:45}
|
||||
*/
|
||||
|
||||
namespace app\common\behavior;
|
||||
|
||||
|
||||
use app\api\logic\LoginLogic;
|
||||
use wanghua\general_utility_tools_php\api\BaseUserLogic;
|
||||
use wanghua\general_utility_tools_php\tool\Tools;
|
||||
|
||||
class LoginBehavior
|
||||
{
|
||||
//public function run(&$params)
|
||||
//{
|
||||
// // 行为逻辑
|
||||
//}
|
||||
|
||||
public function actionBegin(){
|
||||
return true;
|
||||
//白名单
|
||||
$white_arr = [
|
||||
//【全小写】
|
||||
'api/login/login',
|
||||
'api/reg/reg',
|
||||
'api/email/sendemail',
|
||||
'api/email/check',
|
||||
'api/users/forgot',
|
||||
|
||||
//public
|
||||
'api/twitter/search',
|
||||
|
||||
];
|
||||
$module = request()->module();
|
||||
$controller = request()->controller();
|
||||
$action = request()->action();
|
||||
|
||||
if($module != 'api'){
|
||||
return false;
|
||||
}
|
||||
$url = strtolower($module.'/'.$controller.'/'.$action);
|
||||
//dump($url);
|
||||
if(in_array($url, $white_arr)){
|
||||
//dump('不校验');
|
||||
return true;//不校验
|
||||
}
|
||||
|
||||
Tools::log_to_write_txt(['action log'=>input()]);
|
||||
$r = session('api_user_info');
|
||||
//dump($r);die;
|
||||
if(empty($r)){
|
||||
Tools::log_to_write_txt(['api_user_info'=>$r]);
|
||||
echo json_encode(Tools::set_fail('登录失效'),JSON_UNESCAPED_UNICODE);die;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user