|
|
@@ -3,7 +3,7 @@ package com.uas.sso.controller;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.uas.sso.SSOHelper;
|
|
|
import com.uas.sso.SSOToken;
|
|
|
-import com.uas.sso.foreign.bihe.entity.BiHeInfo;
|
|
|
+import com.uas.sso.entity.register.SmsPersonalRegister;
|
|
|
import com.uas.sso.core.Step;
|
|
|
import com.uas.sso.core.Type;
|
|
|
import com.uas.sso.core.PasswordStrength;
|
|
|
@@ -19,6 +19,7 @@ import com.uas.sso.service.PersonalAccountService;
|
|
|
import com.uas.sso.service.UserService;
|
|
|
import com.uas.sso.util.CaptchaUtil;
|
|
|
import com.uas.sso.util.IpUtils;
|
|
|
+import com.uas.sso.util.MessageUtils;
|
|
|
import com.uas.sso.util.PasswordLevelUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
@@ -26,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
@@ -34,6 +36,7 @@ import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLDecoder;
|
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
|
+import java.util.Random;
|
|
|
|
|
|
/**
|
|
|
* 个人注册controller
|
|
|
@@ -164,6 +167,44 @@ public class PersonalRegisterController extends BaseController {
|
|
|
return success(new ModelMap("userUU", user.getUserUU()));
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/sms")
|
|
|
+ public ModelMap register(SmsPersonalRegister personalRegister) throws UnsupportedEncodingException {
|
|
|
+ User user = new User();
|
|
|
+ String mobile = personalRegister.getMobile();
|
|
|
+ String password = getPassword(mobile.substring(mobile.length() - 3, mobile.length()));
|
|
|
+ user.setVipName(mobile);
|
|
|
+ user.setMobile(mobile);
|
|
|
+ user.setPassword(password);
|
|
|
+ ModelMap response = register(user, personalRegister.getAppId(), personalRegister.getCode(), personalRegister.getToken(),
|
|
|
+ personalRegister.getBaseUrl(), personalRegister.getT(), personalRegister.getReturnUrl());
|
|
|
+ MessageUtils.sendSms("templateForSendSmsAfterRegisterSuccess", mobile, password);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取密码
|
|
|
+ * @param suffix 密码后缀
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String getPassword(String suffix) {
|
|
|
+ Random random = new Random();
|
|
|
+ String val = "";
|
|
|
+ // 生成4个字母
|
|
|
+ for (int i=0; i<3; i++) {
|
|
|
+ int choice = random.nextInt(2) % 2 == 0 ? 65 : 97;
|
|
|
+ val = val + (char)(choice + random.nextInt(26));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3个数字
|
|
|
+ String number = random.nextInt(999) + 1000 + "";
|
|
|
+ number = number.substring(number.length() - 3, number.length());
|
|
|
+ val = val + number;
|
|
|
+
|
|
|
+ // 后缀
|
|
|
+ val = val + suffix;
|
|
|
+ return val;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取验证码
|
|
|
*
|