Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
熊鹏飞
/
xxljob220
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
00465f53
authored
May 14, 2016
by
xueli.xue
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
新增记住密码功能
parent
baa61b01
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
7 deletions
xxl-job-admin/src/main/java/com/xxl/job/controller/IndexController.java
xxl-job-admin/src/main/java/com/xxl/job/controller/interceptor/PermissionInterceptor.java
xxl-job-admin/src/main/java/com/xxl/job/core/util/CookieUtil.java
xxl-job-admin/src/main/webapp/WEB-INF/template/login.ftl
xxl-job-admin/src/main/java/com/xxl/job/controller/IndexController.java
View file @
00465f53
...
...
@@ -42,11 +42,15 @@ public class IndexController {
@RequestMapping
(
value
=
"login"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
@PermessionLimit
(
limit
=
false
)
public
ReturnT
<
String
>
loginDo
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
userName
,
String
password
){
public
ReturnT
<
String
>
loginDo
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
userName
,
String
password
,
String
ifRemember
){
if
(!
PermissionInterceptor
.
ifLogin
(
request
))
{
if
(
StringUtils
.
isNotBlank
(
userName
)
&&
StringUtils
.
isNotBlank
(
password
)
&&
"admin"
.
equals
(
userName
)
&&
"123456"
.
equals
(
password
))
{
PermissionInterceptor
.
login
(
response
);
boolean
ifRem
=
false
;
if
(
StringUtils
.
isNotBlank
(
ifRemember
)
&&
"on"
.
equals
(
ifRemember
))
{
ifRem
=
true
;
}
PermissionInterceptor
.
login
(
response
,
ifRem
);
}
else
{
return
new
ReturnT
<
String
>(
500
,
"账号或密码错误"
);
}
...
...
xxl-job-admin/src/main/java/com/xxl/job/controller/interceptor/PermissionInterceptor.java
View file @
00465f53
...
...
@@ -18,8 +18,8 @@ public class PermissionInterceptor extends HandlerInterceptorAdapter {
public
static
final
String
LOGIN_IDENTITY_KEY
=
"LOGIN_IDENTITY"
;
public
static
final
String
LOGIN_IDENTITY_VAL
=
"sdf!121sdf$78sd!8"
;
public
static
boolean
login
(
HttpServletResponse
response
){
CookieUtil
.
set
(
response
,
LOGIN_IDENTITY_KEY
,
LOGIN_IDENTITY_VAL
);
public
static
boolean
login
(
HttpServletResponse
response
,
boolean
ifRemember
){
CookieUtil
.
set
(
response
,
LOGIN_IDENTITY_KEY
,
LOGIN_IDENTITY_VAL
,
ifRemember
);
return
true
;
}
public
static
void
logout
(
HttpServletRequest
request
,
HttpServletResponse
response
){
...
...
xxl-job-admin/src/main/java/com/xxl/job/core/util/CookieUtil.java
View file @
00465f53
...
...
@@ -19,10 +19,19 @@ public class CookieUtil {
* @param response
* @param key
* @param value
* @param ifRemember
*/
public
static
void
set
(
HttpServletResponse
response
,
String
key
,
String
value
)
{
public
static
void
set
(
HttpServletResponse
response
,
String
key
,
String
value
,
boolean
ifRemember
)
{
int
age
=
COOKIE_MAX_AGE
;
if
(
ifRemember
)
{
age
=
COOKIE_MAX_AGE
;
}
else
{
age
=
-
1
;
}
Cookie
cookie
=
new
Cookie
(
key
,
value
);
cookie
.
setMaxAge
(
COOKIE_MAX_AGE
);
// Cookie过期时间,单位/秒
cookie
.
setMaxAge
(
age
);
// Cookie过期时间,单位/秒
cookie
.
setPath
(
COOKIE_PATH
);
// Cookie适用的路径
response
.
addCookie
(
cookie
);
}
...
...
xxl-job-admin/src/main/webapp/WEB-INF/template/login.ftl
View file @
00465f53
...
...
@@ -26,7 +26,7 @@
<div
class=
"col-xs-8"
>
<div
class=
"checkbox icheck"
>
<label>
<input
type=
"checkbox"
>
Remember Me
<input
type=
"checkbox"
name=
"ifRemember"
>
Remember Me
</label>
</div>
</div>
<!-- /.col -->
...
...
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