Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
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
hujun
tl_estate
Commits
4a761574
Commit
4a761574
authored
Apr 09, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
权限判定
parent
6bc1d846
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
7 deletions
+24
-7
Basic.php
application/api_broker/extend/Basic.php
+24
-7
No files found.
application/api_broker/extend/Basic.php
View file @
4a761574
...
...
@@ -10,11 +10,8 @@ namespace app\api_broker\extend;
* 基类
*/
use
app\model\AAgents
;
use
app\model\Users
;
use
app\model\GOperatingRecords
;
use
Firebase\JWT\JWT
;
use
think\Controller
;
use
think\Db
;
use
think\Request
;
use
think\Response
;
use
Qiniu
;
...
...
@@ -49,11 +46,12 @@ class Basic extends Controller
/**
* 基础接口SDK
* @param Request|null $request
*/
/**
*
* Basic constructor.
* @param Request|null $request
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
__construct
(
Request
$request
=
null
)
{
...
...
@@ -82,7 +80,8 @@ class Basic extends Controller
$requestPath
=
$this
->
request
->
routeInfo
()[
"rule"
][
0
]
.
"/"
.
$this
->
request
->
routeInfo
()[
"rule"
][
1
];
//过滤掉不需要验证token的接口
if
(
!
in_array
(
trim
(
$requestPath
),
$this
->
filterVerify
))
{
//$this->tokenVerify();
$this
->
tokenVerify
();
$this
->
userAuth
(
trim
(
$requestPath
));
}
unset
(
$this
->
params
[
"AuthToken"
]);
}
...
...
@@ -264,7 +263,25 @@ class Basic extends Controller
return
$result
;
}
/**
* 权限判定
*
* @param $requestPath
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
userAuth
(
$requestPath
){
$agents
=
new
AAgents
();
$is_auth
=
$agents
->
agentsAuthId
(
$this
->
agentId
,
$requestPath
);
if
(
empty
(
$is_auth
[
'id'
])
&&
$this
->
userId
!=
1
)
{
echo
json_encode
(
array
(
"code"
=>
"300"
,
"msg"
=>
"没有权限!"
,
"data"
=>
[],
"type"
=>
"json"
));
exit
;
}
return
true
;
}
}
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