Commit 4ec094d4 by 韦华德

民政单点登录:增加登录验证码

parent 7567e436
......@@ -15,4 +15,8 @@ public class SsoLoginVo {
private String passwd;
private String code;
private String uuid = "";
}
......@@ -2,9 +2,12 @@ package com.zq.system.modules.system.rest;
import com.zq.common.annotation.rest.AnonymousGetMapping;
import com.zq.common.annotation.rest.AnonymousPostMapping;
import com.zq.common.config.redis.RedisUtils;
import com.zq.common.utils.AssertUtils;
import com.zq.common.utils.StringUtils;
import com.zq.common.vo.IdVo;
import com.zq.common.vo.ResultVo;
import com.zq.system.exception.BadRequestException;
import com.zq.system.modules.system.domain.User;
import com.zq.system.modules.system.domain.vo.SsoLoginVo;
import com.zq.system.modules.system.domain.vo.SsoRegisterVo;
......@@ -28,7 +31,7 @@ import javax.servlet.http.HttpServletResponse;
@Api(tags = "单点登录")
@RequestMapping("/sys/sso")
public class SsoController {
private final RedisUtils redisUtils;
private final SsoService ssoService;
@ApiOperation("单点登录")
......@@ -36,7 +39,16 @@ public class SsoController {
public ResultVo login(@RequestBody SsoLoginVo vo, HttpServletRequest request, HttpServletResponse response) {
AssertUtils.hasText(vo.getUsername(), "用户名为空");
AssertUtils.hasText(vo.getPasswd(), "密码为空");
// 查询验证码
String code = (String) redisUtils.get(vo.getUuid());
// 清除验证码
redisUtils.del(vo.getUuid());
if (StringUtils.isBlank(code)) {
throw new BadRequestException("验证码不存在或已过期");
}
if (StringUtils.isBlank(vo.getCode()) || !vo.getCode().equalsIgnoreCase(code)) {
throw new BadRequestException("验证码错误");
}
return ResultVo.success(ssoService.login(vo, request, response));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment