|
@@ -18,11 +18,11 @@
|
|
|
package org.dromara.maxkey.web.contorller;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
-import java.util.regex.Pattern;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.dromara.maxkey.authn.jwt.AuthTokenService;
|
|
|
import org.dromara.maxkey.configuration.ApplicationConfig;
|
|
|
+import org.dromara.maxkey.constants.ConstsRegex;
|
|
|
import org.dromara.maxkey.constants.ConstsStatus;
|
|
|
import org.dromara.maxkey.crypto.password.PasswordReciprocal;
|
|
|
import org.dromara.maxkey.entity.Message;
|
|
@@ -36,22 +36,21 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
-import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import jakarta.servlet.ServletException;
|
|
|
|
|
|
|
|
|
-@Controller
|
|
|
+@RestController
|
|
|
@RequestMapping(value={"/signup"})
|
|
|
public class RegisterController {
|
|
|
private static Logger logger = LoggerFactory.getLogger(RegisterController.class);
|
|
|
-
|
|
|
- Pattern mobileRegex = Pattern.compile("^[1][3,4,5,7,8][0-9]{9}$");
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
AuthTokenService authTokenService;
|
|
|
|
|
@@ -67,14 +66,12 @@ public class RegisterController {
|
|
|
@Autowired
|
|
|
PasswordEncoder passwordEncoder;
|
|
|
|
|
|
- @ResponseBody
|
|
|
- @RequestMapping(value = { "/produceOtp" }, produces = {MediaType.APPLICATION_JSON_VALUE})
|
|
|
- public Message<?> produceOtp(
|
|
|
- @RequestParam String mobile) {
|
|
|
+ @GetMapping(value = { "/produceOtp" }, produces = {MediaType.APPLICATION_JSON_VALUE})
|
|
|
+ public Message<?> produceOtp(@RequestParam String mobile) {
|
|
|
logger.debug("/signup/produceOtp Mobile {}: " ,mobile);
|
|
|
|
|
|
- logger.debug("Mobile Regex matches {}",mobileRegex.matcher(mobile).matches());
|
|
|
- if(StringUtils.isNotBlank(mobile) && mobileRegex.matcher(mobile).matches()) {
|
|
|
+ logger.debug("Mobile Regex matches {}",ConstsRegex.MOBILE_PATTERN.matcher(mobile).matches());
|
|
|
+ if(StringUtils.isNotBlank(mobile) && ConstsRegex.MOBILE_PATTERN.matcher(mobile).matches()) {
|
|
|
UserInfo userInfo = new UserInfo();
|
|
|
userInfo.setUsername(mobile);
|
|
|
userInfo.setMobile(mobile);
|
|
@@ -87,11 +84,8 @@ public class RegisterController {
|
|
|
}
|
|
|
|
|
|
//直接注册
|
|
|
- @RequestMapping(value={"/register"})
|
|
|
- @ResponseBody
|
|
|
- public Message<?> register(
|
|
|
- @ModelAttribute UserInfo userInfo,
|
|
|
- @RequestParam String captcha) throws ServletException, IOException {
|
|
|
+ @PostMapping(value={"/register"})
|
|
|
+ public Message<?> register(@ModelAttribute UserInfo userInfo , @RequestParam String captcha) throws ServletException, IOException {
|
|
|
UserInfo validateUserInfo = new UserInfo();
|
|
|
validateUserInfo.setUsername(userInfo.getMobile());
|
|
|
validateUserInfo.setMobile(userInfo.getMobile());
|