104 行
2.7 KiB
PHP
104 行
2.7 KiB
PHP
<?php
|
|
// 完整测试权限验证流程
|
|
session_start();
|
|
|
|
// 设置必要的常量和session
|
|
define('MODULE_NAME', 'Retail');
|
|
define('CONTROLLER_NAME', 'Xcx');
|
|
define('ACTION_NAME', 'storeSet');
|
|
define('IS_POST', true);
|
|
|
|
// 模拟登录用户session
|
|
$_SESSION['jurisdiction_user'] = array(
|
|
'id' => 1,
|
|
'login_name' => '13888888888',
|
|
'jurisdiction_group_id' => 1,
|
|
'merchantid' => 1
|
|
);
|
|
|
|
$_SESSION['ls_userinfo'] = array(
|
|
'id' => 1,
|
|
'username' => '13888888888'
|
|
);
|
|
|
|
$_SESSION['storeid'] = 1;
|
|
|
|
echo "Session设置完成\n";
|
|
print_r($_SESSION);
|
|
|
|
// 模拟ThinkPHP的配置
|
|
function C($key) {
|
|
$config = array(
|
|
'DB_PREFIX' => 'ls_'
|
|
);
|
|
return isset($config[$key]) ? $config[$key] : null;
|
|
}
|
|
|
|
// 模拟M函数
|
|
class MockModel {
|
|
private $table;
|
|
private $where;
|
|
|
|
public function __construct($table = null) {
|
|
$this->table = $table;
|
|
}
|
|
|
|
public function table($table) {
|
|
$this->table = $table;
|
|
return $this;
|
|
}
|
|
|
|
public function where($where) {
|
|
$this->where = $where;
|
|
return $this;
|
|
}
|
|
|
|
public function field($field) {
|
|
return $this;
|
|
}
|
|
|
|
public function find() {
|
|
// 模拟找到权限规则
|
|
if ($this->table == 'ls_jurisdiction_list') {
|
|
return array('path' => '/index.php/Retail/Xcx/manager,/index.php/Retail/Xcx/storeSet');
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public function select() {
|
|
if ($this->table == 'ls_jurisdiction_group') {
|
|
return array(
|
|
array(
|
|
'id' => 1,
|
|
'jurisdiction_id' => '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,85,86,87,88,89,90,93,94,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,922,928,1005,1006,1009,1010,1091,1126,1177,1179,1199,1202,1203,1206,1208,471'
|
|
)
|
|
);
|
|
}
|
|
if ($this->table == 'ls_jurisdiction_list') {
|
|
return array(
|
|
array('path' => '/index.php/Retail/Xcx/manager,/index.php/Retail/Xcx/storeSet')
|
|
);
|
|
}
|
|
return array();
|
|
}
|
|
}
|
|
|
|
function M($table = null) {
|
|
return new MockModel($table);
|
|
}
|
|
|
|
// 引入Auth类
|
|
require_once './ThinkPHP/Library/Think/Auth.class.php';
|
|
|
|
// 测试权限验证
|
|
$Auth = new Auth();
|
|
echo "\n\n开始权限验证...\n";
|
|
$result = $Auth->check(1);
|
|
echo "权限验证结果: " . ($result ? '通过' : '失败') . "\n";
|
|
|
|
if (!$result) {
|
|
echo "权限验证失败,这就是接口返回权限错误的原因\n";
|
|
} else {
|
|
echo "权限验证通过,问题可能在其他地方\n";
|
|
}
|
|
?>
|