Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
1f568612
Commit
1f568612
authored
Aug 04, 2017
by
naan1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
记住我功能
parent
8a46ee22
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
15 deletions
+26
-15
src/main/java/com/stylefeng/guns/modular/system/controller/LoginController.java
+11
-5
src/main/webapp/WEB-INF/view/login.html
+15
-10
No files found.
src/main/java/com/stylefeng/guns/modular/system/controller/LoginController.java
View file @
1f568612
...
@@ -46,7 +46,7 @@ public class LoginController extends BaseController {
...
@@ -46,7 +46,7 @@ public class LoginController extends BaseController {
public
String
index
(
Model
model
)
{
public
String
index
(
Model
model
)
{
//获取菜单列表
//获取菜单列表
List
<
Integer
>
roleList
=
ShiroKit
.
getUser
().
getRoleList
();
List
<
Integer
>
roleList
=
ShiroKit
.
getUser
().
getRoleList
();
if
(
roleList
==
null
||
roleList
.
size
()
==
0
)
{
if
(
roleList
==
null
||
roleList
.
size
()
==
0
)
{
ShiroKit
.
getSubject
().
logout
();
ShiroKit
.
getSubject
().
logout
();
model
.
addAttribute
(
"tips"
,
"该用户没有角色,无法登陆"
);
model
.
addAttribute
(
"tips"
,
"该用户没有角色,无法登陆"
);
return
"/login.html"
;
return
"/login.html"
;
...
@@ -84,19 +84,25 @@ public class LoginController extends BaseController {
...
@@ -84,19 +84,25 @@ public class LoginController extends BaseController {
String
username
=
super
.
getPara
(
"username"
).
trim
();
String
username
=
super
.
getPara
(
"username"
).
trim
();
String
password
=
super
.
getPara
(
"password"
).
trim
();
String
password
=
super
.
getPara
(
"password"
).
trim
();
String
remember
=
super
.
getPara
(
"remember"
);
//验证验证码是否正确
//验证验证码是否正确
if
(
ToolUtil
.
getKaptchaOnOff
())
{
if
(
ToolUtil
.
getKaptchaOnOff
())
{
String
kaptcha
=
super
.
getPara
(
"kaptcha"
).
trim
();
String
kaptcha
=
super
.
getPara
(
"kaptcha"
).
trim
();
String
code
=
(
String
)
super
.
getSession
().
getAttribute
(
Constants
.
KAPTCHA_SESSION_KEY
);
String
code
=
(
String
)
super
.
getSession
().
getAttribute
(
Constants
.
KAPTCHA_SESSION_KEY
);
if
(
ToolUtil
.
isEmpty
(
kaptcha
)
||
!
kaptcha
.
equals
(
code
))
{
if
(
ToolUtil
.
isEmpty
(
kaptcha
)
||
!
kaptcha
.
equals
(
code
))
{
throw
new
InvalidKaptchaException
();
throw
new
InvalidKaptchaException
();
}
}
}
}
Subject
currentUser
=
ShiroKit
.
getSubject
();
Subject
currentUser
=
ShiroKit
.
getSubject
();
UsernamePasswordToken
token
=
new
UsernamePasswordToken
(
username
,
password
.
toCharArray
());
UsernamePasswordToken
token
=
new
UsernamePasswordToken
(
username
,
password
.
toCharArray
());
token
.
setRememberMe
(
true
);
if
(
"on"
.
equals
(
remember
))
{
token
.
setRememberMe
(
true
);
}
else
{
token
.
setRememberMe
(
false
);
}
currentUser
.
login
(
token
);
currentUser
.
login
(
token
);
...
@@ -106,7 +112,7 @@ public class LoginController extends BaseController {
...
@@ -106,7 +112,7 @@ public class LoginController extends BaseController {
LogManager
.
me
().
executeLog
(
LogTaskFactory
.
loginLog
(
shiroUser
.
getId
(),
getIp
()));
LogManager
.
me
().
executeLog
(
LogTaskFactory
.
loginLog
(
shiroUser
.
getId
(),
getIp
()));
ShiroKit
.
getSession
().
setAttribute
(
"sessionFlag"
,
true
);
ShiroKit
.
getSession
().
setAttribute
(
"sessionFlag"
,
true
);
return
REDIRECT
+
"/"
;
return
REDIRECT
+
"/"
;
}
}
...
...
src/main/webapp/WEB-INF/view/login.html
View file @
1f568612
...
@@ -36,15 +36,20 @@
...
@@ -36,15 +36,20 @@
<input
type=
"password"
name=
"password"
class=
"form-control"
placeholder=
"密码"
required=
""
>
<input
type=
"password"
name=
"password"
class=
"form-control"
placeholder=
"密码"
required=
""
>
</div>
</div>
@if(tool.getKaptchaOnOff() == true){
@if(tool.getKaptchaOnOff() == true){
<div
class=
"form-group"
style=
"float: left;"
>
<div
class=
"form-group"
style=
"float: left;"
>
<div
class=
"col-sm-8"
style=
"padding-left: 0px; padding-right: 0px;"
>
<div
class=
"col-sm-8"
style=
"padding-left: 0px; padding-right: 0px;"
>
<input
class=
"form-control"
type=
"text"
name=
"kaptcha"
placeholder=
"验证码"
required=
""
>
<input
class=
"form-control"
type=
"text"
name=
"kaptcha"
placeholder=
"验证码"
required=
""
>
</div>
<div
class=
"col-sm-4"
style=
"padding-left: 0px; padding-right: 0px;"
>
<img
src=
"${ctxPath}/kaptcha"
id=
"kaptcha"
width=
"100%"
height=
"100%"
/>
</div>
</div>
</div>
<div
class=
"col-sm-4"
style=
"padding-left: 0px; padding-right: 0px;"
>
<img
src=
"${ctxPath}/kaptcha"
id=
"kaptcha"
width=
"100%"
height=
"100%"
/>
</div>
</div>
@}
@}
<div
class=
"checkbox"
style=
"text-align: left"
>
<label>
<input
type=
"checkbox"
name=
"remember"
style=
"margin-top: 2px;"
>
记住我
</label>
</div>
<button
type=
"submit"
class=
"btn btn-primary block full-width m-b"
>
登 录
</button>
<button
type=
"submit"
class=
"btn btn-primary block full-width m-b"
>
登 录
</button>
</p>
</p>
</form>
</form>
...
@@ -52,9 +57,9 @@
...
@@ -52,9 +57,9 @@
</div>
</div>
<script>
<script>
$
(
function
()
{
$
(
function
()
{
$
(
"#kaptcha"
).
on
(
'click'
,
function
()
{
$
(
"#kaptcha"
).
on
(
'click'
,
function
()
{
$
(
"#kaptcha"
).
attr
(
'src'
,
'${ctxPath}/kaptcha?'
+
Math
.
floor
(
Math
.
random
()
*
100
)
).
fadeIn
();
$
(
"#kaptcha"
).
attr
(
'src'
,
'${ctxPath}/kaptcha?'
+
Math
.
floor
(
Math
.
random
()
*
100
)
).
fadeIn
();
});
});
});
});
</script>
</script>
...
...
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