Skip to content

Commit e01a8a2

Browse files
gadfly3173colorful3
authored andcommitted
fix: 不开启验证码时要求header的错误
1 parent 360f7aa commit e01a8a2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/main/java/io/github/talelin/latticy/controller/cms/UserController.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.github.talelin.latticy.controller.cms;
22

3-
import io.github.talelin.autoconfigure.exception.ForbiddenException;
43
import io.github.talelin.autoconfigure.exception.NotFoundException;
54
import io.github.talelin.autoconfigure.exception.ParameterException;
65
import io.github.talelin.core.annotation.AdminRequired;
@@ -78,14 +77,14 @@ public CreatedVO register(@RequestBody @Validated RegisterDTO validator) {
7877
* 用户登陆
7978
*/
8079
@PostMapping("/login")
81-
public Tokens login(@RequestBody @Validated LoginDTO validator, @RequestHeader("Tag") String tag) {
82-
// TODO: 使用spring validation验证。暂时还没想到怎么根据配置文件分组
80+
public Tokens login(@RequestBody @Validated LoginDTO validator, @RequestHeader(value = "Tag", required = false) String tag) {
8381
if (captchaConfig.getEnabled()) {
82+
// TODO: 使用spring validation验证。暂时还没想到怎么根据配置文件分组
8483
if (!StringUtils.hasText(validator.getCaptcha()) || !StringUtils.hasText(tag)) {
8584
throw new ParameterException("验证码不可为空");
8685
}
8786
if (!userService.verifyCaptcha(validator.getCaptcha(), tag)) {
88-
throw new ForbiddenException(10260);
87+
throw new ParameterException(10260);
8988
}
9089
}
9190
UserDO user = userService.getUserByUsername(validator.getUsername());

0 commit comments

Comments
 (0)