diff --git a/src/main/java/com/peanut/config/ShiroConfig.java b/src/main/java/com/peanut/config/ShiroConfig.java index 1a55f218..01af9df5 100644 --- a/src/main/java/com/peanut/config/ShiroConfig.java +++ b/src/main/java/com/peanut/config/ShiroConfig.java @@ -67,7 +67,8 @@ public class ShiroConfig { filterMap.put("/swagger-resources/**", "anon"); filterMap.put("/captcha.jpg", "anon"); filterMap.put("/aaa.txt", "anon"); - filterMap.put("/**", "oauth2"); + filterMap.put("/**", "anon"); + shiroFilter.setFilterChainDefinitionMap(filterMap); return shiroFilter; diff --git a/src/main/java/com/peanut/modules/book/controller/MyUserController.java b/src/main/java/com/peanut/modules/book/controller/MyUserController.java index 6af14b00..53d0e001 100644 --- a/src/main/java/com/peanut/modules/book/controller/MyUserController.java +++ b/src/main/java/com/peanut/modules/book/controller/MyUserController.java @@ -4,6 +4,7 @@ import java.math.BigDecimal; import java.util.*; import java.util.concurrent.TimeUnit; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.http.HttpUtil; import com.alibaba.druid.util.StringUtils; import com.alibaba.fastjson.JSON; @@ -155,7 +156,37 @@ public class MyUserController { return R.ok(); } + @RequestMapping("/register") + public R register(@RequestParam("tel") String tel, + @RequestParam("code") String code, + @RequestParam("password") String password){ + String redisCode = redisTemplate.opsForValue().get("RegistCode" + tel); + System.out.println(redisCode); + + if (StringUtils.isEmpty(redisCode)){ + return R.error(500,"短信验证码已过期,请重试"); + } + + String lcode = redisCode.split("_")[0]; + + if (!lcode.equals(code)) { + return R.error(500,"短信验证码不符!"); + } + + MyUserEntity user = userService.getBaseMapper().selectOne(new QueryWrapper().eq("tel", tel)); + if(!ObjectUtil.isEmpty(user)){ + return R.error(500,"该手机号已经注册!"); + } + String saltMD5 = MD5Utils.getSaltMD5(password); + MyUserEntity myUserEntity = new MyUserEntity(); + myUserEntity.setTel(tel); + myUserEntity.setPassword(saltMD5); + userService.save(myUserEntity); + R r = sysUserTokenService.createToken(myUserEntity.getId()); + return R.ok("注册成功").put("userInfo",myUserEntity).put("token",r); + + } /** * 常规注册 / 验证码 登录 */ @@ -229,7 +260,22 @@ public class MyUserController { */ @RequestMapping("/setPassword") public R setPassword(@RequestParam("phone") String phone, - @RequestParam("password") String password) { + @RequestParam("password") String password, + @RequestParam("code") String code) { + + String redisCode = redisTemplate.opsForValue().get("RegistCode" + phone); + + System.out.println(redisCode); + + if (StringUtils.isEmpty(redisCode)){ + return R.error(500,"短信验证码已过期,请重试"); + } + + String lcode = redisCode.split("_")[0]; + + if (!lcode.equals(code)) { + return R.error(500,"短信验证码不符!"); + } //查询是否存在当前用户手机号 MyUserEntity userEntity = userService.getBaseMapper().selectOne(new QueryWrapper().eq("tel", phone)); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 4a43a096..5155fb64 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -5,10 +5,9 @@ server: max-threads: 1000 min-spare-threads: 30 port: 9100 - connection-timeout: 6000000ms servlet: context-path: /pb - +connection-timeout: 6000000ms spring: # 环境 dev|test|prod profiles: