Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finance-manage
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
finance-oa
finance-manage
Commits
7b894da4
Commit
7b894da4
authored
Jul 13, 2021
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
参数管理支持配置验证码开关
parent
c8b66f9b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
762 additions
and
701 deletions
+762
-701
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java
...va/com/ruoyi/web/controller/common/CaptchaController.java
+12
-2
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
...java/com/ruoyi/framework/web/service/SysLoginService.java
+33
-11
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java
...main/java/com/ruoyi/system/service/ISysConfigService.java
+7
-0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java
...a/com/ruoyi/system/service/impl/SysConfigServiceImpl.java
+15
-0
ruoyi-ui/src/views/login.vue
ruoyi-ui/src/views/login.vue
+10
-4
sql/ry_20210713.sql
sql/ry_20210713.sql
+685
-684
No files found.
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java
View file @
7b894da4
...
...
@@ -17,6 +17,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import
com.ruoyi.common.core.redis.RedisCache
;
import
com.ruoyi.common.utils.sign.Base64
;
import
com.ruoyi.common.utils.uuid.IdUtils
;
import
com.ruoyi.system.service.ISysConfigService
;
/**
* 验证码操作处理
...
...
@@ -38,13 +39,23 @@ public class CaptchaController
// 验证码类型
@Value
(
"${ruoyi.captchaType}"
)
private
String
captchaType
;
@Autowired
private
ISysConfigService
configService
;
/**
* 生成验证码
*/
@GetMapping
(
"/captchaImage"
)
public
AjaxResult
getCode
(
HttpServletResponse
response
)
throws
IOException
{
AjaxResult
ajax
=
AjaxResult
.
success
();
boolean
captchaOnOff
=
configService
.
selectCaptchaOnOff
();
ajax
.
put
(
"captchaOnOff"
,
captchaOnOff
);
if
(!
captchaOnOff
)
{
return
ajax
;
}
// 保存验证码信息
String
uuid
=
IdUtils
.
simpleUUID
();
String
verifyKey
=
Constants
.
CAPTCHA_CODE_KEY
+
uuid
;
...
...
@@ -78,7 +89,6 @@ public class CaptchaController
return
AjaxResult
.
error
(
e
.
getMessage
());
}
AjaxResult
ajax
=
AjaxResult
.
success
();
ajax
.
put
(
"uuid"
,
uuid
);
ajax
.
put
(
"img"
,
Base64
.
encode
(
os
.
toByteArray
()));
return
ajax
;
...
...
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
View file @
7b894da4
...
...
@@ -21,6 +21,7 @@ import com.ruoyi.common.utils.ServletUtils;
import
com.ruoyi.common.utils.ip.IpUtils
;
import
com.ruoyi.framework.manager.AsyncManager
;
import
com.ruoyi.framework.manager.factory.AsyncFactory
;
import
com.ruoyi.system.service.ISysConfigService
;
import
com.ruoyi.system.service.ISysUserService
;
/**
...
...
@@ -43,6 +44,9 @@ public class SysLoginService
@Autowired
private
ISysUserService
userService
;
@Autowired
private
ISysConfigService
configService
;
/**
* 登录验证
*
...
...
@@ -54,18 +58,11 @@ public class SysLoginService
*/
public
String
login
(
String
username
,
String
password
,
String
code
,
String
uuid
)
{
String
verifyKey
=
Constants
.
CAPTCHA_CODE_KEY
+
uuid
;
String
captcha
=
redisCache
.
getCacheObject
(
verifyKey
);
redisCache
.
deleteObject
(
verifyKey
);
if
(
captcha
==
null
)
{
AsyncManager
.
me
().
execute
(
AsyncFactory
.
recordLogininfor
(
username
,
Constants
.
LOGIN_FAIL
,
MessageUtils
.
message
(
"user.jcaptcha.expire"
)));
throw
new
CaptchaExpireException
();
}
if
(!
code
.
equalsIgnoreCase
(
captcha
))
boolean
captchaOnOff
=
configService
.
selectCaptchaOnOff
();
// 验证码开关
if
(
captchaOnOff
)
{
AsyncManager
.
me
().
execute
(
AsyncFactory
.
recordLogininfor
(
username
,
Constants
.
LOGIN_FAIL
,
MessageUtils
.
message
(
"user.jcaptcha.error"
)));
throw
new
CaptchaException
();
validateCapcha
(
username
,
code
,
uuid
);
}
// 用户验证
Authentication
authentication
=
null
;
...
...
@@ -95,6 +92,31 @@ public class SysLoginService
return
tokenService
.
createToken
(
loginUser
);
}
/**
* 校验验证码
*
* @param username 用户名
* @param code 验证码
* @param uuid 唯一标识
* @return 结果
*/
public
void
validateCapcha
(
String
username
,
String
code
,
String
uuid
)
{
String
verifyKey
=
Constants
.
CAPTCHA_CODE_KEY
+
uuid
;
String
captcha
=
redisCache
.
getCacheObject
(
verifyKey
);
redisCache
.
deleteObject
(
verifyKey
);
if
(
captcha
==
null
)
{
AsyncManager
.
me
().
execute
(
AsyncFactory
.
recordLogininfor
(
username
,
Constants
.
LOGIN_FAIL
,
MessageUtils
.
message
(
"user.jcaptcha.expire"
)));
throw
new
CaptchaExpireException
();
}
if
(!
code
.
equalsIgnoreCase
(
captcha
))
{
AsyncManager
.
me
().
execute
(
AsyncFactory
.
recordLogininfor
(
username
,
Constants
.
LOGIN_FAIL
,
MessageUtils
.
message
(
"user.jcaptcha.error"
)));
throw
new
CaptchaException
();
}
}
/**
* 记录登录信息
*/
...
...
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java
View file @
7b894da4
...
...
@@ -26,6 +26,13 @@ public interface ISysConfigService
*/
public
String
selectConfigByKey
(
String
configKey
);
/**
* 获取验证码开关
*
* @return true开启,false关闭
*/
public
boolean
selectCaptchaOnOff
();
/**
* 查询参数配置列表
*
...
...
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java
View file @
7b894da4
...
...
@@ -80,6 +80,21 @@ public class SysConfigServiceImpl implements ISysConfigService
return
StringUtils
.
EMPTY
;
}
/**
* 获取验证码开关
*
* @return true开启,false关闭
*/
public
boolean
selectCaptchaOnOff
()
{
String
captchaOnOff
=
selectConfigByKey
(
"sys.account.captchaOnOff"
);
if
(
StringUtils
.
isEmpty
(
captchaOnOff
))
{
return
true
;
}
return
Convert
.
toBool
(
captchaOnOff
);
}
/**
* 查询参数配置列表
*
...
...
ruoyi-ui/src/views/login.vue
View file @
7b894da4
...
...
@@ -18,7 +18,7 @@
<svg-icon
slot=
"prefix"
icon-class=
"password"
class=
"el-input__icon input-icon"
/>
</el-input>
</el-form-item>
<el-form-item
prop=
"code"
>
<el-form-item
prop=
"code"
v-if=
"captchaOnOff"
>
<el-input
v-model=
"loginForm.code"
auto-complete=
"off"
...
...
@@ -81,6 +81,7 @@ export default {
code
:
[{
required
:
true
,
trigger
:
"
change
"
,
message
:
"
验证码不能为空
"
}]
},
loading
:
false
,
captchaOnOff
:
true
,
redirect
:
undefined
};
},
...
...
@@ -99,8 +100,11 @@ export default {
methods
:
{
getCode
()
{
getCodeImg
().
then
(
res
=>
{
this
.
codeUrl
=
"
data:image/gif;base64,
"
+
res
.
img
;
this
.
loginForm
.
uuid
=
res
.
uuid
;
this
.
captchaOnOff
=
res
.
captchaOnOff
===
undefined
?
true
:
res
.
captchaOnOff
;
if
(
this
.
captchaOnOff
)
{
this
.
codeUrl
=
"
data:image/gif;base64,
"
+
res
.
img
;
this
.
loginForm
.
uuid
=
res
.
uuid
;
}
});
},
getCookie
()
{
...
...
@@ -130,7 +134,9 @@ export default {
this
.
$router
.
push
({
path
:
this
.
redirect
||
"
/
"
}).
catch
(()
=>
{});
}).
catch
(()
=>
{
this
.
loading
=
false
;
this
.
getCode
();
if
(
this
.
captchaOnOff
)
{
this
.
getCode
();
}
});
}
});
...
...
sql/ry_20210
210
.sql
→
sql/ry_20210
713
.sql
View file @
7b894da4
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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