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
6671a94e
Commit
6671a94e
authored
Mar 01, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
token验证
parent
4294e4cb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
19 deletions
+53
-19
Broker.php
application/api_broker/controller/Broker.php
+13
-0
Basic.php
application/api_broker/extend/Basic.php
+38
-16
SecretReport.php
application/model/SecretReport.php
+1
-3
route.php
application/route.php
+1
-0
No files found.
application/api_broker/controller/Broker.php
View file @
6671a94e
...
...
@@ -342,4 +342,16 @@ class Broker extends Basic
return
$this
->
response
(
$data
[
'status'
],
$data
[
'msg'
],
$data
[
'data'
]);
}
/**
* 生成token(临时用)
*
* @return \think\Response
*/
public
function
token
(){
$jwt
=
new
JwtUntils
();
$phone
=
$this
->
params
[
'phone'
];
$token
=
$jwt
->
createToken
(
$phone
);
return
$this
->
response
(
200
,
""
,
[
'AuthToken'
=>
$token
]);
}
}
\ No newline at end of file
application/api_broker/extend/Basic.php
View file @
6671a94e
...
...
@@ -13,6 +13,7 @@ use app\model\AAgents;
use
app\model\Users
;
use
app\model\GOperatingRecords
;
use
think\Controller
;
use
think\Db
;
use
think\Request
;
use
think\Response
;
use
Qiniu
;
...
...
@@ -37,7 +38,7 @@ class Basic extends Controller
protected
$agentPhone
;
protected
$timeStamp_
;
protected
$filterVerify
=
array
(
'broker/
logi
n'
'broker/
toke
n'
);
/**
...
...
@@ -60,21 +61,42 @@ class Basic extends Controller
}
elseif
(
strtoupper
(
$this
->
request
->
method
())
===
"POST"
)
{
$this
->
params
=
$this
->
request
->
param
()
!=
null
?
$this
->
request
->
param
()
:
null
;
}
// if (isset($this->params['AuthToken']) && $this->params['AuthToken'] != 'null' && !empty($this->params['AuthToken'])) {
// $jwt = new \Firebase\JWT\JWT();
// $this->authToken = $this->params['AuthToken'];
// $result = $jwt->decode($this->authToken, config('jwt_key'), array( 'HS256' )); //解码token
// $this->agentId = $result->data->id;
// $this->agentPhone = $result->data->phone;
// $this->agentName = $result->data->userNick;
// $this->timeStamp_ = $result->timeStamp_;
// }
//
// $requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1];
// //过滤掉不需要验证token的接口
// if (!in_array(trim($requestPath), $this->filterVerify)) {
// $this->tokenVerify();
// }
/*临时验证 start*/
if
(
isset
(
$this
->
params
[
'AuthToken'
])
&&
$this
->
params
[
'AuthToken'
]
!=
'null'
&&
!
empty
(
$this
->
params
[
'AuthToken'
]))
{
$jwt
=
new
JWT
();
$this
->
authToken
=
$this
->
params
[
'AuthToken'
];
$result
=
$jwt
->
decode
(
$this
->
authToken
,
config
(
'jwt_key'
),
array
(
'HS256'
));
//解码token
$this
->
timeStamp_
=
$result
->
timeStamp_
;
$is
=
Db
::
table
(
'agents'
)
->
where
(
'phone'
,
$result
->
data
)
->
count
();
if
(
$is
==
0
)
{
echo
json_encode
(
array
(
"code"
=>
"300"
,
"msg"
=>
"用户验证失败,重新登录!"
,
"data"
=>
[],
"type"
=>
"json"
));
exit
;
}
}
$requestPath
=
$this
->
request
->
routeInfo
()[
"rule"
][
0
]
.
"/"
.
$this
->
request
->
routeInfo
()[
"rule"
][
1
];
if
(
!
in_array
(
trim
(
$requestPath
),
$this
->
filterVerify
))
{
$this
->
tokenVerify
();
}
/*临时验证 end*/
/* if (isset($this->params['AuthToken']) && $this->params['AuthToken'] != 'null' && !empty($this->params['AuthToken'])) {
$jwt = new \Firebase\JWT\JWT();
$this->authToken = $this->params['AuthToken'];
$result = $jwt->decode($this->authToken, config('jwt_key'), array( 'HS256' )); //解码token
$this->userId = $result->data->id;
$this->phone = $result->data->phone;
$this->userNick = $result->data->userNick;
$this->timeStamp_ = $result->timeStamp_;
}
$requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1];
//过滤掉不需要验证token的接口
if (!in_array(trim($requestPath), $this->filterVerify)) {
$this->tokenVerify();
}*/
}
...
...
application/model/SecretReport.php
View file @
6671a94e
...
...
@@ -138,7 +138,7 @@ class SecretReport extends Model
$result
=
[];
foreach
(
$data
as
$k
=>
$v
)
{
$result
[
$k
]
=
$v
;
$result
[
$k
][
'price'
]
=
""
;
if
(
$v
->
agents_id
)
{
$agents_data
=
Db
::
table
(
'agents'
)
->
field
(
'realName,father_id'
)
->
where
(
'id'
,
$v
->
agents_id
)
->
find
();
$result
[
$k
][
'agents_name'
]
=
$agents_data
[
'realName'
];
...
...
@@ -162,8 +162,6 @@ class SecretReport extends Model
$time
+=
floor
(
$v
->
time
/
60
);
}
$result
[
$k
][
'price'
]
=
$time
*
0.06
+
$time
*
0.05
;
//通话 0.06元/分,录音 0.05元/分
}
else
{
$result
[
$k
][
'price'
]
=
""
;
}
}
...
...
application/route.php
View file @
6671a94e
...
...
@@ -272,6 +272,7 @@ Route::group('broker', [
'getShopList'
=>
[
'api_broker/Shop/getShopList'
,
[
'method'
=>
'get|post'
]
],
'getShopDetail'
=>
[
'api_broker/Shop/getShopDetail'
,
[
'method'
=>
'get'
]
],
'reportList'
=>
[
'api_broker/Report/reportList'
,
[
'method'
=>
'get'
]
],
'token'
=>
[
'api_broker/broker/token'
,
[
'method'
=>
'get'
]
],
]);
...
...
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