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
c85364d6
Commit
c85364d6
authored
May 23, 2017
by
fsn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加一个开关,控制登录页面的验证码
parent
3e6d7e6d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
1 deletions
+49
-1
src/main/java/com/stylefeng/guns/config/properties/GunsProperties.java
+27
-0
src/main/java/com/stylefeng/guns/core/util/ToolUtil.java
+12
-0
src/main/java/com/stylefeng/guns/modular/system/controller/LoginController.java
+3
-1
src/main/resources/application.yml
+5
-0
src/main/webapp/WEB-INF/view/login.html
+2
-0
No files found.
src/main/java/com/stylefeng/guns/config/properties/GunsProperties.java
0 → 100644
View file @
c85364d6
package
com
.
stylefeng
.
guns
.
config
.
properties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.stereotype.Component
;
/**
* guns项目配置
*
* @author stylefeng
* @Date 2017/5/23 22:31
*/
@Component
@ConfigurationProperties
(
prefix
=
GunsProperties
.
PREFIX
)
public
class
GunsProperties
{
public
static
final
String
PREFIX
=
"guns"
;
private
Boolean
kaptchaOpen
;
public
Boolean
getKaptchaOpen
()
{
return
kaptchaOpen
;
}
public
void
setKaptchaOpen
(
Boolean
kaptchaOpen
)
{
this
.
kaptchaOpen
=
kaptchaOpen
;
}
}
src/main/java/com/stylefeng/guns/core/util/ToolUtil.java
View file @
c85364d6
...
...
@@ -15,6 +15,7 @@
*/
package
com
.
stylefeng
.
guns
.
core
.
util
;
import
com.stylefeng.guns.config.properties.GunsProperties
;
import
com.stylefeng.guns.core.support.StrKit
;
import
java.io.IOException
;
...
...
@@ -523,4 +524,14 @@ public class ToolUtil {
public
static
String
firstLetterToLower
(
String
val
){
return
StrKit
.
firstCharToLowerCase
(
val
);
}
/**
* 获取验证码开关
*
* @author stylefeng
* @Date 2017/5/23 22:34
*/
public
static
Boolean
getKaptchaOnOff
(){
return
SpringContextHolder
.
getBean
(
GunsProperties
.
class
).
getKaptchaOpen
();
}
}
\ No newline at end of file
src/main/java/com/stylefeng/guns/modular/system/controller/LoginController.java
View file @
c85364d6
...
...
@@ -83,13 +83,15 @@ public class LoginController extends BaseController {
String
username
=
super
.
getPara
(
"username"
).
trim
();
String
password
=
super
.
getPara
(
"password"
).
trim
();
String
kaptcha
=
super
.
getPara
(
"kaptcha"
).
trim
();
//验证验证码是否正确
if
(
ToolUtil
.
getKaptchaOnOff
()){
String
kaptcha
=
super
.
getPara
(
"kaptcha"
).
trim
();
String
code
=
(
String
)
super
.
getSession
().
getAttribute
(
Constants
.
KAPTCHA_SESSION_KEY
);
if
(
ToolUtil
.
isEmpty
(
kaptcha
)
||
!
kaptcha
.
equals
(
code
)){
throw
new
InvalidKaptchaException
();
}
}
Subject
currentUser
=
ShiroKit
.
getSubject
();
UsernamePasswordToken
token
=
new
UsernamePasswordToken
(
username
,
password
.
toCharArray
());
...
...
src/main/resources/application.yml
View file @
c85364d6
################### guns项目独有的配置 ###################
guns
:
kaptcha-open
:
false
#是否开启登录时验证码 (true/false)
################### 项目启动端口 ###################
server
:
port
:
80
...
...
src/main/webapp/WEB-INF/view/login.html
View file @
c85364d6
...
...
@@ -35,6 +35,7 @@
<div
class=
"form-group"
>
<input
type=
"password"
name=
"password"
class=
"form-control"
placeholder=
"密码"
required=
""
>
</div>
@if(tool.getKaptchaOnOff() == true){
<div
class=
"form-group"
style=
"float: left;"
>
<div
class=
"col-sm-8"
style=
"padding-left: 0px; padding-right: 0px;"
>
<input
class=
"form-control"
type=
"text"
name=
"kaptcha"
placeholder=
"验证码"
required=
""
>
...
...
@@ -43,6 +44,7 @@
<img
src=
"${ctxPath}/kaptcha"
id=
"kaptcha"
width=
"100%"
height=
"100%"
/>
</div>
</div>
@}
<button
type=
"submit"
class=
"btn btn-primary block full-width m-b"
>
登 录
</button>
</p>
</form>
...
...
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