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
b2d7c537
Commit
b2d7c537
authored
Jan 18, 2019
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登录优化
parent
eaa06b05
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
16 deletions
+15
-16
config.php
application/config.php
+1
-1
Login.php
application/index/controller/Login.php
+3
-0
Basic.php
application/index/extend/Basic.php
+11
-15
No files found.
application/config.php
View file @
b2d7c537
...
@@ -231,7 +231,7 @@ return [
...
@@ -231,7 +231,7 @@ return [
// 是否自动开启 SESSION
// 是否自动开启 SESSION
'auto_start'
=>
true
,
'auto_start'
=>
true
,
//过期时间
//过期时间
'expire'
=>
360
00
'expire'
=>
72
00
],
],
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
...
...
application/index/controller/Login.php
View file @
b2d7c537
...
@@ -11,6 +11,7 @@ use app\model\ASite;
...
@@ -11,6 +11,7 @@ use app\model\ASite;
use
app\model\AStore
;
use
app\model\AStore
;
use
app\model\AuthGroup
;
use
app\model\AuthGroup
;
use
app\model\AuthRule
;
use
app\model\AuthRule
;
use
think\Config
;
use
think\Session
;
use
think\Session
;
/**
/**
...
@@ -163,8 +164,10 @@ class Login extends Basic
...
@@ -163,8 +164,10 @@ class Login extends Basic
$jwt_data
[
'level'
]
=
$user_data
[
'level'
];
$jwt_data
[
'level'
]
=
$user_data
[
'level'
];
$user_data
[
'AuthToken'
]
=
$jwt
->
createToken
(
$jwt_data
);
$user_data
[
'AuthToken'
]
=
$jwt
->
createToken
(
$jwt_data
);
$expire_time
=
Config
::
get
(
'session.expire'
)
+
time
()
-
30
;
Session
::
set
(
"userName"
,
$user_data
[
"name"
]);
Session
::
set
(
"userName"
,
$user_data
[
"name"
]);
Session
::
set
(
"userId"
,
$user_data
[
"id"
]);
Session
::
set
(
"userId"
,
$user_data
[
"id"
]);
Session
::
set
(
"expire_time"
,
$expire_time
);
Session
::
set
(
"lastLoginTime"
,
time
());
Session
::
set
(
"lastLoginTime"
,
time
());
Session
::
set
(
"user_info"
,
$user_data
);
Session
::
set
(
"user_info"
,
$user_data
);
$this
->
operating_records
(
$user_data
[
"id"
],
1
,
'后台登陆'
);
//记录操作日志
$this
->
operating_records
(
$user_data
[
"id"
],
1
,
'后台登陆'
);
//记录操作日志
...
...
application/index/extend/Basic.php
View file @
b2d7c537
...
@@ -14,7 +14,9 @@ use app\model\AAgents;
...
@@ -14,7 +14,9 @@ use app\model\AAgents;
use
app\model\GHousesToAgents
;
use
app\model\GHousesToAgents
;
use
app\model\GOperatingRecords
;
use
app\model\GOperatingRecords
;
use
app\model\Users
;
use
app\model\Users
;
use
think\Config
;
use
think\Controller
;
use
think\Controller
;
use
think\Cookie
;
use
think\Request
;
use
think\Request
;
use
think\Response
;
use
think\Response
;
use
think\Session
;
use
think\Session
;
...
@@ -35,6 +37,7 @@ class Basic extends Controller
...
@@ -35,6 +37,7 @@ class Basic extends Controller
public
$userId
;
public
$userId
;
public
$expire_time
;
public
$lastLoginTime
;
public
$lastLoginTime
;
public
$city
;
public
$city
;
...
@@ -228,7 +231,7 @@ class Basic extends Controller
...
@@ -228,7 +231,7 @@ class Basic extends Controller
if
(
empty
(
$is_auth
)
&&
$this
->
userId
!=
1
)
{
if
(
empty
(
$is_auth
)
&&
$this
->
userId
!=
1
)
{
if
(
$this
->
request
->
isAjax
()){
if
(
$this
->
request
->
isAjax
()){
echo
json_encode
(
array
(
"code"
=>
"30
0
"
,
"msg"
=>
"没有权限!"
,
"data"
=>
[],
"type"
=>
"json"
));
exit
;
echo
json_encode
(
array
(
"code"
=>
"30
1
"
,
"msg"
=>
"没有权限!"
,
"data"
=>
[],
"type"
=>
"json"
));
exit
;
}
else
{
}
else
{
$this
->
error
(
'没有当前页面权限'
);
exit
;
$this
->
error
(
'没有当前页面权限'
);
exit
;
}
}
...
@@ -243,27 +246,20 @@ class Basic extends Controller
...
@@ -243,27 +246,20 @@ class Basic extends Controller
*/
*/
public
function
userVerify
(){
public
function
userVerify
(){
$this
->
lastLoginTime
=
Session
::
get
(
"lastLoginTime"
);
$this
->
lastLoginTime
=
Session
::
get
(
"lastLoginTime"
);
if
(
empty
(
$this
->
userName
)
||
empty
(
$this
->
userId
)
||
empty
(
$this
->
lastLoginTime
)
){
$this
->
expire_time
=
Session
::
get
(
"expire_time"
);
if
(
empty
(
$this
->
lastLoginTime
)){
if
(
$this
->
request
->
isAjax
())
{
if
(
$this
->
request
->
isAjax
())
{
echo
json_encode
(
array
(
"code"
=>
"
101
"
,
"msg"
=>
"登录失效,请重新登录"
,
"data"
=>
[],
"type"
=>
"json"
));
exit
;
echo
json_encode
(
array
(
"code"
=>
"
300
"
,
"msg"
=>
"登录失效,请重新登录"
,
"data"
=>
[],
"type"
=>
"json"
));
exit
;
}
else
{
}
else
{
$this
->
redirect
(
'/index/login'
);
$this
->
redirect
(
'/index/login'
);
}
}
}
}
$time
=
time
();
if
(
$this
->
expire_time
<
time
())
{
//登录有效期判断
$expire
=
Config
::
get
(
'session.expire'
);
if
((
$time
-
$this
->
lastLoginTime
)
>
36000
)
{
$expire
=
empty
(
$expire
)
?
7200
:
$expire
;
if
(
$this
->
request
->
isAjax
())
{
Cookie
::
set
(
'PHPSESSID'
,
session_id
(),
$expire
);
//更新session_id过期时间
echo
json_encode
(
array
(
"code"
=>
"101"
,
"msg"
=>
"登录失效,请重新登录"
,
"data"
=>
[],
"type"
=>
"json"
));
exit
;
}
else
{
$this
->
redirect
(
'/index/login'
);
die
;
}
}
else
{
//更新时间
Session
::
set
(
"lastLoginTime"
,
$time
);
}
}
return
;
return
;
}
}
...
...
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