This commit is contained in:
mashuai 2024-06-11 13:15:03 +08:00
parent 6020a1929d
commit 338d1e6a20
1 changed files with 5 additions and 6 deletions

View File

@ -67,11 +67,11 @@ public class TokenController {
*/ */
@PostMapping("login") @PostMapping("login")
public R<?> login(@RequestBody LoginBody form) throws Exception { public R<?> login(@RequestBody LoginBody form) throws Exception {
if ("admin".equals(form.getUsername())) {
//根据用户名查询用户信息 //根据用户名查询用户信息
LoginUser userInfo = sysLoginService.selectByName(form.getUsername()); LoginUser user = sysLoginService.selectByName(form.getUsername());
//获取查询的用户手机号 //获取查询的用户手机号
String phone = userInfo.getSysUser().getPhonenumber(); String phone = user.getSysUser().getPhonenumber();
if ("admin".equals(form.getUsername())) {
if (!StringUtils.isNotBlank(phone)) { if (!StringUtils.isNotBlank(phone)) {
throw new ServiceException("手机号为空,请联系管理员!"); throw new ServiceException("手机号为空,请联系管理员!");
} }
@ -82,8 +82,6 @@ public class TokenController {
} }
if (!StringUtils.equals(redisCode.split(GlobalConstants.STRING_UNDERLINE)[0], form.getTextCode())) { if (!StringUtils.equals(redisCode.split(GlobalConstants.STRING_UNDERLINE)[0], form.getTextCode())) {
throw new ServiceException("短信验证码错误", 500); throw new ServiceException("短信验证码错误", 500);
} else {
redisService.deleteObject("code_" + phone);
} }
} }
String uuid = form.getUuid(); String uuid = form.getUuid();
@ -101,6 +99,7 @@ public class TokenController {
return R.fail("图形验证码超时,请重新刷新"); return R.fail("图形验证码超时,请重新刷新");
} }
if (form.getCode() != null && form.getCode().equals(captcha)) { if (form.getCode() != null && form.getCode().equals(captcha)) {
redisService.deleteObject("code_" + phone);
// 获取登录token // 获取登录token
return R.ok(tokenService.createToken(userInfo)); return R.ok(tokenService.createToken(userInfo));
} else { } else {