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
03ed22ee
Commit
03ed22ee
authored
Feb 01, 2018
by
zfcaa
Committed by
zfc
Feb 01, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登录
parent
5e43b422
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
5 deletions
+70
-5
Login.php
application/index/controller/Login.php
+50
-2
AAgents.php
application/model/AAgents.php
+9
-3
AuthRule.php
application/model/AuthRule.php
+11
-0
No files found.
application/index/controller/Login.php
View file @
03ed22ee
...
...
@@ -5,6 +5,7 @@ namespace app\index\controller;
use
app\index\extend\Basic
;
use
app\model\AAgents
;
use
app\model\AdminModel
;
use
app\model\AuthRule
;
use
think\Request
;
use
think\Session
;
...
...
@@ -20,11 +21,13 @@ class Login extends Basic
protected
$loginDb
;
protected
$loginagent
;
protected
$authrule
;
public
function
__construct
(
$request
=
null
)
{
parent
::
__construct
(
$request
);
$this
->
loginDb
=
new
AdminModel
();
$this
->
loginagent
=
new
AAgents
();
$this
->
authrule
=
new
AuthRule
();
}
public
function
login
()
...
...
@@ -61,9 +64,54 @@ class Login extends Basic
return
view
(
"/login/login"
,
[
"msg"
=>
"用户名或密码错误"
]);
}
}
else
{
//条件
$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"
;
$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'
]
];
$params
[
"name"
]
=
$name
;
$params
[
"pswd"
]
=
md5
(
md5
(
$passwd
));
$this
->
loginagent
->
verifyUser
(
$params
);
$passwd
=
md5
(
$passwd
);
$where
=
"(name='
{
$name
}
'or phone='
{
$name
}
') and password='
$passwd
' "
;
$list
=
$this
->
loginagent
->
verifyUser
(
$field
,
$join
,
$where
);
if
(
!
$list
){
return
view
(
"/login/login"
,
[
"msg"
=>
"用户名或密码错误"
]);
}
//prt($list->toArray());//转化arr
if
(
$list
[
'admin_off'
]
!=
'0'
||
empty
(
$list
[
'rules'
])){
return
view
(
"/login/login"
,
[
"msg"
=>
"用户无后台访问权限"
]);
}
else
{
$rules
=
trim
(
$list
[
'rules'
],
','
);
$where
=
"id in(
{
$rules
}
)and is_menu=1 and status=1 and pid=1 "
;
$list
[
'nav'
]
=
$this
->
authrule
->
loginRule
(
$where
);
foreach
(
$list
[
'nav'
]
as
$k
=>
$v
){
// prt($v->toArray());
$where
=
"pid='
{
$v
[
'id'
]
}
' and id in(
{
$rules
}
) and is_menu=0 and status=1 "
;
$r
=
$this
->
authrule
->
loginRule
(
$where
);
if
(
$r
){
// prt($r);
// // prt($r->toArray());//转化arr
// exit;
$list
[
'rules'
][
$k
][
'cz'
]
=
$r
;
}
}
prt
(
$list
->
toArray
());
//转化arr
exit
;
}
Session
::
set
(
"userName"
,
$list
[
"name"
]);
Session
::
set
(
"userId"
,
$list
[
"id"
]);
Session
::
set
(
"userinfo"
,
$list
);
Session
::
set
(
"lastLoginTime"
,
time
());
$this
->
operating_records
(
$result
[
0
][
"id"
],
1
,
'后台登陆'
);
//记录操作日志
$this
->
redirect
(
'/admin.php/index/banner'
);
}
...
...
application/model/AAgents.php
View file @
03ed22ee
...
...
@@ -107,11 +107,16 @@ public function saveList(){
return
$data
;
}
public
function
verifyUser
(
$params
)
public
function
verifyUser
(
$
field
,
$join
,
$
params
)
{
return
$this
->
db
$r
=
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
$join
)
->
where
(
$params
)
->
select
();
->
find
();
// echo $this->getLastSql();
return
$r
;
}
}
\ No newline at end of file
application/model/AuthRule.php
View file @
03ed22ee
...
...
@@ -106,5 +106,15 @@ class AuthRule extends BaseModel
return
false
;
}
}
public
function
loginRule
(
$where
){
$r
=
$this
->
field
(
'id,name,title'
)
->
where
(
$where
)
->
select
();
$this
->
getLastSql
();
return
$r
;
}
}
\ No newline at end of file
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