Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
喜欢杯子
microservices-platform
提交
02c56a12
microservices-platform
项目概览
喜欢杯子
/
microservices-platform
与 Fork 源项目一致
Fork自
whatyn / microservices-platform
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
microservices-platform
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
02c56a12
编写于
8月 09, 2019
作者:
zlt2000
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化图像验证码,改为gif动图
上级
d0d7deaf
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
28 addition
and
29 deletion
+28
-29
pom.xml
pom.xml
+9
-5
zlt-uaa/pom.xml
zlt-uaa/pom.xml
+4
-3
zlt-uaa/src/main/java/com/central/oauth/controller/ValidateCodeController.java
.../com/central/oauth/controller/ValidateCodeController.java
+13
-19
zlt-uaa/src/main/java/com/central/oauth/service/impl/ValidateCodeServiceImpl.java
...m/central/oauth/service/impl/ValidateCodeServiceImpl.java
+1
-1
zlt-web/back-web/src/main/resources/static/login.html
zlt-web/back-web/src/main/resources/static/login.html
+1
-1
未找到文件。
pom.xml
浏览文件 @
02c56a12
...
...
@@ -26,7 +26,7 @@
<security-oauth2.version>
2.3.5.RELEASE
</security-oauth2.version>
<security-jwt.version>
1.0.9.RELEASE
</security-jwt.version>
<redisson.version>
3.9.1
</redisson.version>
<
kaptcha.version>
0.0.9
</k
aptcha.version>
<
easyCaptcha.version>
1.5.0
</easyC
aptcha.version>
<hutool.version>
4.6.1
</hutool.version>
<mybatis-plus-boot-starter.version>
3.1.2
</mybatis-plus-boot-starter.version>
<aliyun-sdk-oss>
3.4.2
</aliyun-sdk-oss>
...
...
@@ -202,11 +202,11 @@
<artifactId>
swagger-butler-core
</artifactId>
<version>
${swagger.butler.version}
</version>
</dependency>
<!--
kaptcha
验证码生成工具 -->
<!-- 验证码生成工具 -->
<dependency>
<groupId>
com.github.
axet
</groupId>
<artifactId>
k
aptcha
</artifactId>
<version>
${
k
aptcha.version}
</version>
<groupId>
com.github.
whvcse
</groupId>
<artifactId>
EasyC
aptcha
</artifactId>
<version>
${
easyC
aptcha.version}
</version>
</dependency>
<!-- hutool java工具类库 -->
<dependency>
...
...
@@ -359,6 +359,10 @@
<enabled>
false
</enabled>
</snapshots>
</repository>
<repository>
<id>
jitpack.io
</id>
<url>
https://jitpack.io
</url>
</repository>
</repositories>
<distributionManagement>
<repository>
...
...
zlt-uaa/pom.xml
浏览文件 @
02c56a12
...
...
@@ -50,10 +50,11 @@
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
</dependency>
<!--
kaptcha
验证码生成工具 -->
<!-- 验证码生成工具 -->
<dependency>
<groupId>
com.github.axet
</groupId>
<artifactId>
kaptcha
</artifactId>
<groupId>
com.github.whvcse
</groupId>
<artifactId>
EasyCaptcha
</artifactId>
<version>
1.5.0
</version>
</dependency>
<dependency>
...
...
zlt-uaa/src/main/java/com/central/oauth/controller/ValidateCodeController.java
浏览文件 @
02c56a12
...
...
@@ -3,7 +3,9 @@ package com.central.oauth.controller;
import
com.central.common.constant.SecurityConstants
;
import
com.central.common.model.Result
;
import
com.central.oauth.service.IValidateCodeService
;
import
com.google.code.kaptcha.Producer
;
import
com.wf.captcha.Captcha
;
import
com.wf.captcha.GifCaptcha
;
import
com.wf.captcha.utils.CaptchaUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.util.Assert
;
...
...
@@ -11,10 +13,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.imageio.ImageIO
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
java.awt.image.BufferedImage
;
/**
* 验证码提供
...
...
@@ -23,9 +22,6 @@ import java.awt.image.BufferedImage;
*/
@Controller
public
class
ValidateCodeController
{
@Autowired
private
Producer
producer
;
@Autowired
private
IValidateCodeService
validateCodeService
;
...
...
@@ -37,18 +33,16 @@ public class ValidateCodeController {
@GetMapping
(
SecurityConstants
.
DEFAULT_VALIDATE_CODE_URL_PREFIX
+
"/{deviceId}"
)
public
void
createCode
(
@PathVariable
String
deviceId
,
HttpServletResponse
response
)
throws
Exception
{
Assert
.
notNull
(
deviceId
,
"机器码不能为空"
);
response
.
setHeader
(
"Cache-Control"
,
"no-store, no-cache"
);
response
.
setContentType
(
"image/jpeg"
);
//生成文字验证码
String
text
=
producer
.
createText
();
//生成图片验证码
BufferedImage
image
=
producer
.
createImage
(
text
);
validateCodeService
.
saveImageCode
(
deviceId
,
text
);
try
(
ServletOutputStream
out
=
response
.
getOutputStream
()
)
{
ImageIO
.
write
(
image
,
"JPEG"
,
out
);
}
// 设置请求头为输出图片类型
CaptchaUtil
.
setHeader
(
response
);
// 三个参数分别为宽、高、位数
GifCaptcha
gifCaptcha
=
new
GifCaptcha
(
100
,
35
,
4
);
// 设置类型:字母数字混合
gifCaptcha
.
setCharType
(
Captcha
.
TYPE_DEFAULT
);
// 保存验证码
validateCodeService
.
saveImageCode
(
deviceId
,
gifCaptcha
.
text
().
toLowerCase
());
// 输出图片流
gifCaptcha
.
out
(
response
.
getOutputStream
());
}
/**
...
...
zlt-uaa/src/main/java/com/central/oauth/service/impl/ValidateCodeServiceImpl.java
浏览文件 @
02c56a12
...
...
@@ -115,7 +115,7 @@ public class ValidateCodeServiceImpl implements IValidateCodeService {
throw
new
ValidateCodeException
(
"验证码不存在或已过期"
);
}
if
(!
StringUtils
.
equals
(
code
,
codeInRequest
))
{
if
(!
StringUtils
.
equals
(
code
,
codeInRequest
.
toLowerCase
()
))
{
throw
new
ValidateCodeException
(
"验证码不正确"
);
}
...
...
zlt-web/back-web/src/main/resources/static/login.html
浏览文件 @
02c56a12
...
...
@@ -98,7 +98,7 @@
});
}
else
{
layer
.
closeAll
(
'
loading
'
);
layer
.
msg
(
'
登录失败,请重试
'
,
{
icon
:
5
,
time
:
500
});
layer
.
msg
(
data
.
resp_msg
,
{
icon
:
5
,
time
:
500
});
}
},
error
:
function
(
xhr
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录