|
@@ -193,6 +193,7 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
|
@Override
|
|
|
public String getRangeCode(String appId) {
|
|
|
+ UserAuthDto userAuthDto = new UserAuthDto();
|
|
|
LoginUser currentUser = UserUtil.getCurrentUser();
|
|
|
Integer id = currentUser.getId();
|
|
|
String appSecret=userMapper.getAppSecret(appId);
|
|
@@ -206,12 +207,14 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
|
|
|
|
if(uniqueUserID!=null){
|
|
|
+ userAuthDto.setUniqId(uniqueUserID);
|
|
|
+ userAuthDto.setMobile(currentUser.getPhoneNumber());
|
|
|
for (int i=0;i<6;i++)
|
|
|
{
|
|
|
code+=random.nextInt(10);
|
|
|
}
|
|
|
String key=code+"_"+appId+"_"+appSecret;
|
|
|
- redisUtil.set(key,uniqueUserID);
|
|
|
+ redisUtil.set(key, JSONObject.toJSONString(userAuthDto));
|
|
|
redisUtil.setExpire(key,300);
|
|
|
}
|
|
|
|
|
@@ -226,7 +229,6 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
|
@Override
|
|
|
public UserAuthDto getUniqId(String appId, String encryptValue) {
|
|
|
- UserAuthDto resultDto = new UserAuthDto();
|
|
|
String appSecret = userMapper.getAppSecret(appId);
|
|
|
if (StringUtils.isEmpty(appSecret)){
|
|
|
throw new ServiceException(ResultStatus.USER_AUTH_APPID_NOT_FOUND);
|
|
@@ -234,14 +236,11 @@ public class UserServiceImpl implements UserService {
|
|
|
String key = null;
|
|
|
try {
|
|
|
// 验证加密的内容是否正确
|
|
|
- // key = AESUtils.decryptString(encryptValue, appSecret);
|
|
|
key = DESUtil.decrypt(encryptValue,appSecret);
|
|
|
- // 获取明文
|
|
|
- String text = key.substring(0, key.lastIndexOf("_"));
|
|
|
- // 获取时间
|
|
|
+ // 截取里面的时间
|
|
|
String date = key.substring(key.lastIndexOf("_") + 1, key.length());
|
|
|
- // 验证在1-2分钟之内是否是有效的加密
|
|
|
- if (!DESUtil.verifyTime(Long.parseLong(date))){
|
|
|
+ // 验证在5分钟之内是否是有效的加密
|
|
|
+ if (!DESUtil.verifyTime(Long.parseLong(date), 5)){
|
|
|
throw new ServiceException(ResultStatus.USER_AUTH_ENCRYPT_VALUE_VERIFY_ERROR);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@@ -251,8 +250,9 @@ public class UserServiceImpl implements UserService {
|
|
|
if (StringUtils.isEmpty(value)){
|
|
|
throw new ServiceException(ResultStatus.USER_AUTH_UNIQID_OR_CODE_ISNULL);
|
|
|
}
|
|
|
- resultDto.setUniqId(value);
|
|
|
- return resultDto;
|
|
|
+ UserAuthDto dto = JSONObject.parseObject(value,UserAuthDto.class);
|
|
|
+ dto.setMessage(key);
|
|
|
+ return dto;
|
|
|
}
|
|
|
|
|
|
|