解决注册验证码错误问题、日志报空指针问题

This commit is contained in:
yuyang 2022-06-15 09:26:17 +08:00
parent 90e93b2774
commit 6024588155
2 changed files with 12 additions and 2 deletions

View File

@ -108,7 +108,7 @@ public class XhpcAppUserController extends BaseController {
/** /**
* C端用户注册 * C端用户注册
*/ */
@Log(title = "C端用户--注册", businessType = BusinessType.INSERT) //@Log(title = "C端用户--注册", businessType = BusinessType.INSERT)
@ApiOperation("注册") @ApiOperation("注册")
@PostMapping("/register") @PostMapping("/register")
public R<?> register(@RequestBody Map<String, Object> map) { public R<?> register(@RequestBody Map<String, Object> map) {

View File

@ -149,8 +149,11 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
return R.fail(HttpStatus.NOT_NULL, "验证码不能为空"); return R.fail(HttpStatus.NOT_NULL, "验证码不能为空");
} }
String captcha = redisService.getCacheObject("pvToken:" + phone); String captcha = redisService.getCacheObject("pvToken:" + phone);
if(captcha==null || "".equals(captcha)){
return R.fail(HttpStatus.ERROR_STATUS, "验证码错误");
}
if (!code.equalsIgnoreCase(captcha)) { if (!code.equalsIgnoreCase(captcha)) {
R.fail(HttpStatus.ERROR_STATUS, "验证码错误"); return R.fail(HttpStatus.ERROR_STATUS, "验证码错误");
} }
XhpcAppUser info = xhpcAppUserMapper.getAppUserByPhone(phone,tenantId); XhpcAppUser info = xhpcAppUserMapper.getAppUserByPhone(phone,tenantId);
if (StringUtils.isNotNull(info)) { if (StringUtils.isNotNull(info)) {
@ -209,11 +212,15 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
String openid = StringUtils.valueOf(map.get("openid")); String openid = StringUtils.valueOf(map.get("openid"));
logger.info("<<<<<<<<<<openid>>>>>>>>>>>>"); logger.info("<<<<<<<<<<openid>>>>>>>>>>>>");
logger.info("<<<<<<<<<<登录openid>>>>>>>>>>>>"+openid); logger.info("<<<<<<<<<<登录openid>>>>>>>>>>>>"+openid);
logger.info("<<<<<<<<<<openid>>>>>>>>>>>>"); logger.info("<<<<<<<<<<openid>>>>>>>>>>>>");
if (StringUtils.isEmpty(openid)) { if (StringUtils.isEmpty(openid)) {
return R.fail(HttpStatus.NOT_NULL, "openid不能为空"); return R.fail(HttpStatus.NOT_NULL, "openid不能为空");
} }
String captcha = redisService.getCacheObject("pvToken:" + phone); String captcha = redisService.getCacheObject("pvToken:" + phone);
if(null ==captcha || "".equals(captcha)){
return R.fail(HttpStatus.ERROR_STATUS, "验证码错误");
}
if (!code.equalsIgnoreCase(captcha)) { if (!code.equalsIgnoreCase(captcha)) {
return R.fail(HttpStatus.ERROR_STATUS, "验证码错误"); return R.fail(HttpStatus.ERROR_STATUS, "验证码错误");
} }
@ -530,6 +537,9 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
return R.fail(HttpStatus.NOT_NULL, "手机号不能为空"); return R.fail(HttpStatus.NOT_NULL, "手机号不能为空");
} }
String captcha = redisService.getCacheObject("pvToken:" + phone); String captcha = redisService.getCacheObject("pvToken:" + phone);
if(null ==captcha || "".equals(captcha)){
return R.fail(HttpStatus.ERROR_STATUS, "验证码错误");
}
if (!code.equalsIgnoreCase(captcha)) { if (!code.equalsIgnoreCase(captcha)) {
return R.fail(HttpStatus.ERROR_STATUS, "验证码错误"); return R.fail(HttpStatus.ERROR_STATUS, "验证码错误");
} }