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
c7a03fb9
Commit
c7a03fb9
authored
Dec 15, 2017
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
token验证
parent
271ae4a8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
15 deletions
+23
-15
Basic.php
application/api/extend/Basic.php
+23
-15
No files found.
application/api/extend/Basic.php
View file @
c7a03fb9
...
...
@@ -33,9 +33,21 @@ class Basic extends Controller
* @var int userId
*/
protected
$userId
;
protected
$user
_n
ick
;
protected
$user
N
ick
;
protected
$phone
;
protected
$timeStamp_
;
protected
$filterVerify
=
array
(
"api/shopDetail"
,
"api/sendSms"
,
"api/logout"
,
"api/login"
,
"api/register"
,
"api/shopList"
,
"api/filtrateCondition"
,
"api/shopDetail"
,
"api/bannerList"
,
"api/averagePriceAndTurnover"
,
);
/**
* 基础接口SDK
...
...
@@ -43,26 +55,20 @@ class Basic extends Controller
*/
public
function
__construct
(
Request
$request
=
null
)
{
/* ob_start();
ob_end_flush();
ob_end_clean();
ob_get_contents();*/
// CORS 跨域 Options 检测响应
$this
->
corsOptionsHandler
();
// 输入对象
$this
->
request
=
is_null
(
$request
)
?
Request
::
instance
()
:
$request
;
if
(
strtoupper
(
$this
->
request
->
method
())
===
"GET"
)
{
$this
->
params
=
$this
->
request
->
param
();
}
elseif
(
strtoupper
(
$this
->
request
->
method
())
===
"POST"
)
{
$this
->
params
=
$this
->
request
->
param
()
!=
null
?
$this
->
request
->
param
()
:
null
;
}
/*
$requestPath
=
$this
->
request
->
path
();
//过滤掉不需要验证token的接口
if
(
!
in_array
(
trim
(
$requestPath
),
$this
->
filterVerify
))
{
if
(
!
isset
(
$this
->
params
[
'AuthToken'
]))
{
echo
json_encode
(
array
(
"code"
=>
"101"
,
"msg"
=>
"AuthToken不能为空!"
,
"data"
=>
[],
"type"
=>
"json"
));
exit
;
...
...
@@ -72,13 +78,15 @@ class Basic extends Controller
$result
=
$jwt
->
decode
(
$this
->
authToken
,
config
(
'jwt_key'
),
array
(
'HS256'
));
//解码token
$this
->
userId
=
$result
->
data
->
id
;
$this
->
phone
=
$result
->
data
->
phone
;
$this->user_nick = $result->data->user_n
ick;
$this
->
userNick
=
$result
->
data
->
userN
ick
;
$this
->
timeStamp_
=
$result
->
timeStamp_
;
$this->verifyTime();*/
$this
->
verifyUserInfo
();
$this
->
verifyTime
();
}
}
public
function
verifyTime
()
{
$today
=
Time
::
today
();
...
...
@@ -94,7 +102,7 @@ class Basic extends Controller
//todo 待完成
$userModel
=
new
Users
();
$userArr
=
$userModel
->
selectUser
(
$this
->
userId
);
if
(
count
(
$userArr
)
>
0
&&
(
$userArr
[
"id"
]
!=
$this
->
userId
||
$userArr
[
"user_phone"
]
!=
$this
->
phone
))
{
if
(
count
(
$userArr
)
>
0
&&
(
$userArr
[
"id"
]
!=
$this
->
userId
||
$userArr
[
"user_phone"
]
!=
$this
->
phone
))
{
echo
json_encode
(
array
(
"code"
=>
"101"
,
"msg"
=>
"用户验证失败,重新登录!"
,
"data"
=>
[],
"type"
=>
"json"
));
exit
;
}
...
...
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