|
@@ -1178,6 +1178,14 @@ public class AppLoginController extends AppBaseController{
|
|
|
return captchaError;
|
|
return captchaError;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ String redisCode = redisCache.getCacheObject("sms:code:" + phone);
|
|
|
|
|
+ if (StringUtils.isEmpty(redisCode)) {
|
|
|
|
|
+ return R.error("验证码已过期,请重新发送");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!redisCode.equals(code)) {
|
|
|
|
|
+ return R.error("验证码错误");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
String encryptPhone = encryptPhone(phone);
|
|
String encryptPhone = encryptPhone(phone);
|
|
|
List<FsUser> user = userService.selectFsUserListByPhone(encryptPhone);
|
|
List<FsUser> user = userService.selectFsUserListByPhone(encryptPhone);
|
|
|
if (CollectionUtil.isEmpty(user)) {
|
|
if (CollectionUtil.isEmpty(user)) {
|
|
@@ -1186,28 +1194,51 @@ public class AppLoginController extends AppBaseController{
|
|
|
if (CollectionUtil.isEmpty(user)) {
|
|
if (CollectionUtil.isEmpty(user)) {
|
|
|
user = userService.selectFsUserListByPhone(phone);
|
|
user = userService.selectFsUserListByPhone(phone);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ FsUser loginUser;
|
|
|
if (CollectionUtil.isEmpty(user)) {
|
|
if (CollectionUtil.isEmpty(user)) {
|
|
|
- return R.error("此电话号码未绑定用户");
|
|
|
|
|
- }
|
|
|
|
|
- if (user.size() > 1) {
|
|
|
|
|
- user.removeIf(fsUser -> StringUtils.isEmpty(fsUser.getHistoryApp()));
|
|
|
|
|
|
|
+ loginUser = createUserByPhoneLogin(map, phone);
|
|
|
|
|
+ if (loginUser == null) {
|
|
|
|
|
+ return R.error("注册失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (user.size() > 1) {
|
|
|
|
|
+ user.removeIf(fsUser -> StringUtils.isEmpty(fsUser.getHistoryApp()));
|
|
|
|
|
+ }
|
|
|
|
|
+ loginUser = user.get(0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- String redisCode = redisCache.getCacheObject("sms:code:" + phone);
|
|
|
|
|
- if (StringUtils.isEmpty(redisCode)) {
|
|
|
|
|
- return R.error("验证码已过期,请重新发送");
|
|
|
|
|
|
|
+ redisCache.deleteObject(Constants.APP_LOGIN_CAPTCHA_CODE_KEY + captchaUuid);
|
|
|
|
|
+ if (ObjectUtil.isNotNull(map.get("jpushId"))) {
|
|
|
|
|
+ updateExistingUserJpushId(loginUser, map.get("jpushId"));
|
|
|
}
|
|
}
|
|
|
- if (!redisCode.equals(code)) {
|
|
|
|
|
- return R.error("验证码错误");
|
|
|
|
|
|
|
+ if (ObjectUtil.isNotNull(map.get("loginDevice")) || ObjectUtil.isNotNull(map.get("source")) ) {
|
|
|
|
|
+ updateLoginDevice(loginUser.getUserId(), map.get("loginDevice"), map.get("source"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- redisCache.deleteObject(Constants.APP_LOGIN_CAPTCHA_CODE_KEY + captchaUuid);
|
|
|
|
|
- updateExistingUserJpushId(user.get(0), map.get("jpushId"));
|
|
|
|
|
- updateLoginDevice(user.get(0).getUserId(), map.get("loginDevice"), map.get("source"));
|
|
|
|
|
-
|
|
|
|
|
return generateTokenAndReturn(user.get(0));
|
|
return generateTokenAndReturn(user.get(0));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private FsUser createUserByPhoneLogin(Map<String, String> map, String phone) {
|
|
|
|
|
+ FsUser user = new FsUser();
|
|
|
|
|
+ user.setPhone(phone);
|
|
|
|
|
+ user.setJpushId(map.get("jpushId"));
|
|
|
|
|
+ user.setSource(map.get("source"));
|
|
|
|
|
+ user.setNickName("app用户" + phone.substring(phone.length() - 4));
|
|
|
|
|
+ user.setStatus(1);
|
|
|
|
|
+ user.setAvatar("https://cos.his.cdwjyyh.com/fs/20240926/420728ee06e54575ba82665dedb4756b.png");
|
|
|
|
|
+ user.setCreateTime(new Date());
|
|
|
|
|
+ user.setLastIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
|
|
+ String defaultPassword = getUserDefaultPassword();
|
|
|
|
|
+ if (StringUtils.isNotBlank(defaultPassword)) {
|
|
|
|
|
+ user.setPassword(Md5Utils.hash(defaultPassword));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (userService.insertFsUser(user) > 0) {
|
|
|
|
|
+ return user;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private R validateAppLoginCaptcha(String captchaCode, String captchaUuid) {
|
|
private R validateAppLoginCaptcha(String captchaCode, String captchaUuid) {
|
|
|
if (StringUtils.isEmpty(captchaUuid) || StringUtils.isEmpty(captchaCode)) {
|
|
if (StringUtils.isEmpty(captchaUuid) || StringUtils.isEmpty(captchaCode)) {
|
|
|
return R.error("请输入图形验证码");
|
|
return R.error("请输入图形验证码");
|