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
098362ce
Commit
098362ce
authored
Mar 07, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登录代码调整
parent
3085f766
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
99 deletions
+65
-99
Login.php
application/index/controller/Login.php
+65
-99
No files found.
application/index/controller/Login.php
View file @
098362ce
...
...
@@ -3,8 +3,7 @@
namespace
app\index\controller
;
use
app\index\extend\Basic
;
use
app\model\AdminModel
;
use
app\model\Agents
;
use
app\model\AAgents
;
use
app\model\AuthRule
;
use
think\Session
;
...
...
@@ -23,9 +22,8 @@ class Login extends Basic
public
function
__construct
(
$request
=
null
)
{
parent
::
__construct
(
$request
);
$this
->
loginAgent
=
new
Agents
();
$this
->
authRule
=
new
AuthRule
();
$this
->
loginDb
=
new
AdminModel
();
$this
->
loginAgent
=
new
AAgents
();
$this
->
authRule
=
new
AuthRule
();
}
public
function
login
()
...
...
@@ -42,121 +40,89 @@ class Login extends Basic
*/
public
function
loginVerify
()
{
$name
=
$_POST
[
"username"
];
$passwd
=
$_POST
[
"passwd"
];
if
(
!
isset
(
$name
)
||
!
isset
(
$passwd
))
{
return
view
(
"/login/login"
,
[
"msg"
=>
"用户名或密码不能为空"
]);
}
$params
[
"name"
]
=
$name
;
$params
[
"pswd"
]
=
md5
(
$passwd
);
$result
=
$this
->
loginDb
->
verifyUser
(
$params
);
if
(
count
(
$result
)
>
0
)
{
//todo 更新登录信息
$this
->
loginDb
->
updateLoginTime
(
$result
[
0
][
"id"
]);
Session
::
set
(
"userName"
,
$result
[
0
][
"name"
]);
Session
::
set
(
"userId"
,
$result
[
0
][
"id"
]);
Session
::
set
(
"lastLoginTime"
,
time
());
$this
->
operating_records
(
$result
[
0
][
"id"
],
1
,
'后台登陆'
);
//记录操作日志
// $this->redirect('/admin.php/index/banner');
// return view("/admin.php/index/banner", [ "msg" => "用户名或密码错误" ]);
return
$this
->
response
(
'200'
,
'登录成功'
);
}
else
{
// return view("/login/login", [ "msg" => "用户名或密码错误" ]);
return
$this
->
response
(
'101'
,
'用户名或密码错误'
);
}
/*$name = $this->request->param("username");
$name
=
$this
->
request
->
param
(
"username"
);
$password
=
$this
->
request
->
param
(
"passwd"
);
if
(
!
isset
(
$name
)
||
!
isset
(
$password
))
{
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"
;
$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']
$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;
$password = md5($password);
$where="( phone='{$name}') and password='$password' ";
$list=$this->loginAgent->verifyUser($filed,$join,$where);
// prt($list->toArray());//转化arr
if(!$list){
$params
[
"name"
]
=
$name
;
$password
=
md5
(
$password
);
$where
=
"( phone='
{
$name
}
') and password='
$password
' "
;
$list
=
$this
->
loginAgent
->
verifyUser
(
$filed
,
$join
,
$where
);
if
(
!
$list
)
{
return
$this
->
response
(
'101'
,
'用户名或密码错误'
);
}
if($list['g_status']=='1'){
}
if
(
$list
[
'g_status'
]
==
'1'
)
{
return
$this
->
response
(
'102'
,
'用户所在角色组已冻结'
);
}
if($list['admin_off']!='0'||empty($list['rules'])){
return $this->response('103','用户无后台访问权限');
}else{
$rules=trim($list['rules'],',');
//查询后台菜单
$where ="id in({$rules})and is_menu=1 and status=0 and pid=1 ";
$nav=$this->authRule->loginRule($where);
$nav2=array();
$url='';//跳转页面
foreach ($nav as $k=> $v){
if($k=='0'){
$url=$v->name;
}
$nav2[$v->id]=$v;
}
if(!$url){
return $this->response('104','用户无任何后台访模块问权限!');
if
(
$list
[
'admin_off'
]
!=
'0'
||
empty
(
$list
[
'rules'
]))
{
return
$this
->
response
(
'103'
,
'用户无后台访问权限'
);
}
else
{
$rules
=
trim
(
$list
[
'rules'
],
','
);
//查询后台菜单
$where
=
"id in(
{
$rules
}
)and is_menu=1 and status=0 and pid=1 "
;
$nav
=
$this
->
authRule
->
loginRule
(
$where
);
$nav2
=
array
();
$url
=
''
;
//跳转页面
foreach
(
$nav
as
$k
=>
$v
){
if
(
$k
==
'0'
){
$url
=
$v
->
name
;
}
$nav2
[
$v
->
id
]
=
$v
;
}
if
(
!
$url
)
{
return
$this
->
response
(
'104'
,
'用户无任何后台访模块问权限!'
);
}
//搜索菜单功能
$where = "id in({$rules}) and is_menu=0 and status=0 ";
$r = $this->authRule->loginRule($where);
$r2 = array();
foreach($r as $v){
$buttonUrl=explode('/',$v->name);
$v['bt']=$buttonUrl[1];
$r2[$v->pid][] = $v;
}
//搜索菜单功能
$where
=
"id in(
{
$rules
}
) and is_menu=0 and status=0 "
;
$r
=
$this
->
authRule
->
loginRule
(
$where
);
$r2
=
array
();
foreach
(
$r
as
$v
)
{
$buttonUrl
=
explode
(
'/'
,
$v
->
name
);
$v
[
'bt'
]
=
$buttonUrl
[
1
];
$r2
[
$v
->
pid
][]
=
$v
;
}
foreach($nav2 as $k=> $v){
if(!empty($r2[$k])){
$nav2[$k]['cz'] = $r2[$k];
}
foreach
(
$nav2
as
$k
=>
$v
){
if
(
!
empty
(
$r2
[
$k
])){
$nav2
[
$k
][
'cz'
]
=
$r2
[
$k
];
}
}
$list['nav'] = $nav2;
$list2 = $list->toArray();//转化arr
$list
[
'nav'
]
=
$nav2
;
$list2
=
$list
->
toArray
();
//转化arr
}
}
Session::set("userName",$list["name"]);
Session::set("userId",$list["id"]);
Session::set("userinfo",$list2);
Session::set("usertable",'agent');
Session::set("lastLoginTime",time());
$this->operating_records($list["id"],1,'后台登陆'); //记录操作日志
$data['url']=$url;
$data['data']=$list2;
if($this->request->isAjax()) {
return $this->response('200', '登录成功', $data);
}else {
$this->redirect('/admin.php/'.$url);
}*/
// }
Session
::
set
(
"userName"
,
$list
[
"name"
]);
Session
::
set
(
"userId"
,
$list
[
"id"
]);
Session
::
set
(
"userinfo"
,
$list2
);
Session
::
set
(
"usertable"
,
'agent'
);
Session
::
set
(
"lastLoginTime"
,
time
());
$this
->
operating_records
(
$list
[
"id"
],
1
,
'后台登陆'
);
//记录操作日志
$data
[
'url'
]
=
$url
;
$data
[
'data'
]
=
$list2
;
if
(
$this
->
request
->
isAjax
())
{
return
$this
->
response
(
'200'
,
'登录成功'
,
$data
);
}
else
{
$this
->
redirect
(
'/admin.php/'
.
$url
);
}
}
/**
...
...
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