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
0beb0a05
Commit
0beb0a05
authored
Jul 18, 2018
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增ip绑定
parent
2dd72272
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
37 deletions
+57
-37
Broker.php
application/api_broker/controller/Broker.php
+2
-2
BrokerService.php
application/api_broker/service/BrokerService.php
+7
-3
Login.php
application/index/controller/Login.php
+44
-31
ABindingDevice.php
application/model/ABindingDevice.php
+4
-1
No files found.
application/api_broker/controller/Broker.php
View file @
0beb0a05
...
...
@@ -141,7 +141,7 @@ class Broker extends Basic
return
$this
->
response
(
101
,
'密码错误'
);
}
//判断设备id是否存在
$is_login
=
$this
->
brokerService
->
judgeBand
(
$params
[
"device_id"
],
$agents_data
[
'id'
],
$params
[
"model"
],
0
,
$params
[
"push_id"
]);
$is_login
=
$this
->
brokerService
->
judgeBand
(
$params
[
"device_id"
],
$agents_data
[
'id'
],
$params
[
"model"
],
0
,
$params
[
"push_id"
]
,
0
);
if
(
!
$is_login
)
{
return
$this
->
response
(
"102"
,
"该账号没有绑定该手机,请致电人事进行绑定。"
);
}
...
...
@@ -184,7 +184,7 @@ class Broker extends Basic
return
$this
->
response
(
"101"
,
$checkResult
);
}
$is_visit
=
$this
->
brokerService
->
judgeBand
(
$params
[
"device_id"
],
$params
[
"agent_id"
],
""
,
1
,
""
);
$is_visit
=
$this
->
brokerService
->
judgeBand
(
$params
[
"device_id"
],
$params
[
"agent_id"
],
""
,
1
,
""
,
0
);
if
(
$is_visit
)
{
return
$this
->
response
(
"200"
,
"success"
,
[]);
}
else
{
...
...
application/api_broker/service/BrokerService.php
View file @
0beb0a05
...
...
@@ -28,11 +28,13 @@ class BrokerService
* @param string $model
* @param int $type 0提交记录到后台, 1仅仅判断
* @param string $push_id
* @param int $is_pc 0 app 1pc端
* @return bool
*/
public
function
judgeBand
(
string
$device_id
,
int
$agent_id
,
string
$model
,
int
$type
,
string
$push_id
)
:
bool
public
function
judgeBand
(
string
$device_id
,
int
$agent_id
,
string
$model
,
int
$type
,
string
$push_id
,
int
$is_pc
)
:
bool
{
$params
[
"agent_id"
]
=
$agent_id
;
$params
[
"is_pc"
]
=
$is_pc
;
$result
=
$this
->
aBD
->
getDeviceByAgentId
(
$params
);
if
(
count
(
$result
)
<=
0
)
{
...
...
@@ -42,7 +44,8 @@ class BrokerService
"agent_id"
=>
$agent_id
,
"model"
=>
$model
,
"push_id"
=>
$push_id
,
"is_forbidden"
=>
0
]);
"is_forbidden"
=>
0
,
"is_pc"
=>
$is_pc
]);
return
true
;
}
$is_exits
=
false
;
...
...
@@ -66,7 +69,8 @@ class BrokerService
"agent_id"
=>
$agent_id
,
"model"
=>
$model
,
"push_id"
=>
$push_id
,
"is_forbidden"
=>
1
]);
"is_forbidden"
=>
1
,
"is_pc"
=>
$is_pc
]);
return
false
;
...
...
application/index/controller/Login.php
View file @
0beb0a05
...
...
@@ -3,6 +3,7 @@
namespace
app\index\controller
;
use
app\api\untils\JwtUntils
;
use
app\api_broker\service\BrokerService
;
use
app\index\extend\Basic
;
use
app\model\AAgents
;
use
app\model\AuthRule
;
...
...
@@ -20,11 +21,14 @@ class Login extends Basic
protected
$loginAgent
;
protected
$authRule
;
protected
$brokerService
;
public
function
__construct
(
$request
=
null
)
{
parent
::
__construct
(
$request
);
$this
->
loginAgent
=
new
AAgents
();
$this
->
authRule
=
new
AuthRule
();
$this
->
loginAgent
=
new
AAgents
();
$this
->
authRule
=
new
AuthRule
();
$this
->
brokerService
=
new
BrokerService
();
}
public
function
login
()
...
...
@@ -43,51 +47,52 @@ class Login extends Basic
*/
public
function
loginVerify
()
{
$name
=
$this
->
request
->
param
(
"username"
);
$name
=
$this
->
request
->
param
(
"username"
);
$password
=
$this
->
request
->
param
(
"passwd"
);
if
(
!
isset
(
$name
)
||
!
isset
(
$password
))
{
return
$this
->
response
(
'100'
,
'用户名或密码不能为空'
);
return
$this
->
response
(
'100'
,
'用户名或密码不能为空'
);
}
$filed
=
" a.id,a.store_id,a.auth_group_id,a.district_id,a.level,a.name,a.phone,a.sex,a.img,a.status,a.admin_off,
ifNull(s.store_name,'')store_name,ifNull(d.district_name,'')district_name,g.rules,g.status as g_status"
;
$join
=
[
[
'a_store s'
,
' a.store_id=a.id'
,
'left'
],
[
'a_district d'
,
'a.district_id=d.id'
,
'left'
],
[
'auth_group g'
,
'a.auth_group_id=g.id'
,
'left'
]
[
'a_store s'
,
' a.store_id=a.id'
,
'left'
],
[
'a_district d'
,
'a.district_id=d.id'
,
'left'
],
[
'auth_group g'
,
'a.auth_group_id=g.id'
,
'left'
]
];
$params
[
"name"
]
=
$name
;
$password
=
md5
(
$password
);
$where
=
"( phone='
{
$name
}
') and password='
$password
' "
;
$list
=
$this
->
loginAgent
->
verifyUser
(
$filed
,
$join
,
$where
);
$password
=
md5
(
$password
);
$where
=
"( phone='
{
$name
}
') and password='
$password
' "
;
$list
=
$this
->
loginAgent
->
verifyUser
(
$filed
,
$join
,
$where
);
if
(
!
$list
)
{
return
$this
->
response
(
'101'
,
'用户名或密码错误'
);
if
(
!
$list
)
{
return
$this
->
response
(
'101'
,
'用户名或密码错误'
);
}
if
(
$list
[
'g_status'
]
==
'1'
)
{
return
$this
->
response
(
'102'
,
'用户所在角色组已冻结'
);
if
(
$list
[
'g_status'
]
==
'1'
)
{
return
$this
->
response
(
'102'
,
'用户所在角色组已冻结'
);
}
if
(
$list
[
'admin_off'
]
!=
'0'
||
empty
(
$list
[
'rules'
])
||
$list
[
'status'
]
!=
'0'
)
{
return
$this
->
response
(
'103'
,
'无后台访问权限'
);
}
else
{
if
(
$list
[
'admin_off'
]
!=
'0'
||
empty
(
$list
[
'rules'
])
||
$list
[
'status'
]
!=
'0'
)
{
return
$this
->
response
(
'103'
,
'无后台访问权限'
);
}
else
{
$where_rule
[
'status'
]
=
0
;
if
(
$list
[
'id'
]
==
1
)
{
//超级管理员
$nav
=
$this
->
authRule
->
getRule
(
''
,
$where_rule
);
$nav
=
$this
->
authRule
->
getRule
(
''
,
$where_rule
);
}
else
{
$where_rule
[
'id'
]
=
[
'in'
,
$list
[
'rules'
]
];
$where_rule
[
'id'
]
=
[
'in'
,
$list
[
'rules'
]
];
//查询后台菜单
$nav
=
$this
->
authRule
->
getRule
(
''
,
$where_rule
);
$nav
=
$this
->
authRule
->
getRule
(
''
,
$where_rule
);
}
$menu_data
=
[];
$auth_data
=
[];
foreach
(
$nav
as
$k
=>
$v
)
{
foreach
(
$nav
as
$k
=>
$v
)
{
if
(
$v
[
'is_menu'
]
==
1
)
{
$menu_data
[
$k
][
'id'
]
=
$v
[
'id'
];
$menu_data
[
$k
][
'name'
]
=
$v
[
'name'
];
...
...
@@ -103,7 +108,14 @@ class Login extends Basic
$list
[
'menu'
]
=
list_to_tree
(
$menu_data
);
$list
[
'auth'
]
=
$auth_data
;
$list
=
$list
->
toArray
();
//转化arr
$list
=
$list
->
toArray
();
//转化arr
}
$last_login_ip
=
ip2long
(
$this
->
request
->
ip
());
//判断设备id是否存在
$is_login
=
$this
->
brokerService
->
judgeBand
(
$last_login_ip
,
$list
[
'id'
],
"浏览器需前端传"
,
0
,
$list
[
'phone'
],
1
);
if
(
!
$is_login
)
{
return
$this
->
response
(
"102"
,
"该账号没有绑定该手机,请致电人事进行绑定。"
);
}
$jwt
=
new
JwtUntils
();
...
...
@@ -113,22 +125,23 @@ class Login extends Basic
$jwt_data
[
'level'
]
=
$list
[
'level'
];
$list
[
'AuthToken'
]
=
$jwt
->
createToken
(
$jwt_data
);
Session
::
set
(
"userName"
,
$list
[
"name"
]);
Session
::
set
(
"userId"
,
$list
[
"id"
]);
Session
::
set
(
"lastLoginTime"
,
time
());
Session
::
set
(
"user_info"
,
$list
);
$this
->
operating_records
(
$list
[
"id"
],
1
,
'后台登陆'
);
//记录操作日志
Session
::
set
(
"userName"
,
$list
[
"name"
]);
Session
::
set
(
"userId"
,
$list
[
"id"
]);
Session
::
set
(
"lastLoginTime"
,
time
());
Session
::
set
(
"user_info"
,
$list
);
$this
->
operating_records
(
$list
[
"id"
],
1
,
'后台登陆'
);
//记录操作日志
if
(
$this
->
request
->
isAjax
())
{
if
(
$this
->
request
->
isAjax
())
{
return
$this
->
response
(
'200'
,
'登录成功'
,
$list
);
}
else
{
}
else
{
$this
->
redirect
(
'/admin.php'
);
}
return
;
return
;
}
public
function
userVerify
(){
public
function
userVerify
()
{
//todo
}
...
...
application/model/ABindingDevice.php
View file @
0beb0a05
...
...
@@ -65,7 +65,7 @@ class ABindingDevice extends BaseModel
* @param string $field
* @return false|\PDOStatement|string|\think\Collection
*/
public
function
getDeviceByAgentId
(
array
$params
,
string
$field
=
"id,agent_id,device_id,is_forbidden,push_id"
)
public
function
getDeviceByAgentId
(
array
$params
,
string
$field
=
"id,agent_id,device_id,is_forbidden,push_id
,is_pc
"
)
{
$where_
=
[];
if
(
isset
(
$params
[
"agent_id"
]))
{
...
...
@@ -77,6 +77,9 @@ class ABindingDevice extends BaseModel
if
(
isset
(
$params
[
"is_forbidden"
]))
{
$where_
[
"is_forbidden"
]
=
$params
[
"is_forbidden"
];
}
if
(
isset
(
$params
[
"is_pc"
]))
{
$where_
[
"is_pc"
]
=
$params
[
"is_pc"
];
}
return
$this
->
field
(
$field
)
->
where
(
$where_
)
...
...
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