|
@@ -4,11 +4,17 @@ import javax.annotation.Resource;
|
|
|
|
|
|
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
|
+import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
import com.ruoyi.common.enums.ErrorCodes;
|
|
import com.ruoyi.common.enums.ErrorCodes;
|
|
|
import com.ruoyi.common.exception.ErrorException;
|
|
import com.ruoyi.common.exception.ErrorException;
|
|
|
import com.ruoyi.common.utils.PhoneUtils;
|
|
import com.ruoyi.common.utils.PhoneUtils;
|
|
|
|
|
+import com.ruoyi.dz.domain.DzCards;
|
|
|
|
|
+import com.ruoyi.dz.service.IDzCardsService;
|
|
|
|
|
+import com.ruoyi.dz.service.impl.DzCardsServiceImpl;
|
|
|
import com.ruoyi.framework.web.service.TokenService;
|
|
import com.ruoyi.framework.web.service.TokenService;
|
|
|
import com.ruoyi.system.service.ShortMessageService;
|
|
import com.ruoyi.system.service.ShortMessageService;
|
|
|
|
|
+import com.ruoyi.web.controller.dz.DzCardsController;
|
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.authentication.AuthenticationManager;
|
|
import org.springframework.security.authentication.AuthenticationManager;
|
|
@@ -38,11 +44,13 @@ import com.ruoyi.system.service.ISysConfigService;
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 登录校验方法
|
|
* 登录校验方法
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @author ruoyi
|
|
* @author ruoyi
|
|
|
*/
|
|
*/
|
|
|
@Component
|
|
@Component
|
|
@@ -56,7 +64,7 @@ public class SysLoginService
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
private RedisCache redisCache;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ISysUserService userService;
|
|
private ISysUserService userService;
|
|
|
|
|
|
|
@@ -65,6 +73,8 @@ public class SysLoginService
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ShortMessageService shortMessageService;
|
|
private ShortMessageService shortMessageService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IDzCardsService cardsService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 登录验证
|
|
* 登录验证
|
|
@@ -77,6 +87,7 @@ public class SysLoginService
|
|
|
*/
|
|
*/
|
|
|
public AjaxResult login(String mobile, String username, String password, String code, String uuid) {
|
|
public AjaxResult login(String mobile, String username, String password, String code, String uuid) {
|
|
|
if (StringUtils.isNotBlank(mobile)) {
|
|
if (StringUtils.isNotBlank(mobile)) {
|
|
|
|
|
+ //手机验证码登录:{code: "9", uuid: "cc94320c3fce4db5898213b727ac1dc0", mobile: "18774924158", password: "1234"}
|
|
|
if (!shortMessageService.checkCode(mobile, password)) {
|
|
if (!shortMessageService.checkCode(mobile, password)) {
|
|
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(mobile, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
|
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(mobile, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
|
|
|
throw new CaptchaException();
|
|
throw new CaptchaException();
|
|
@@ -86,9 +97,22 @@ public class SysLoginService
|
|
|
password = UserConstants.LOGIN_SMS_PASS;
|
|
password = UserConstants.LOGIN_SMS_PASS;
|
|
|
} else {
|
|
} else {
|
|
|
// 验证码校验
|
|
// 验证码校验
|
|
|
|
|
+ // 卡密登录json:{code: "0", uuid: "a9eee0b6729f42c4862a57acef8a4bdd", username: "20000025", password: "123456"}
|
|
|
validateCaptcha(username, code, uuid);
|
|
validateCaptcha(username, code, uuid);
|
|
|
// 登录前置校验
|
|
// 登录前置校验
|
|
|
loginPreCheck(username, password);
|
|
loginPreCheck(username, password);
|
|
|
|
|
+ //卡密登录时,要将卡的密码转换为用户的密码
|
|
|
|
|
+ DzCards card = cardsService.selectDzCardsByCardNo(username);
|
|
|
|
|
+ if (null==card){
|
|
|
|
|
+ return AjaxResult.error("卡不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!password.trim().equalsIgnoreCase(card.getPassword())){
|
|
|
|
|
+ return AjaxResult.error("密码错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ String dbPwd = userService.selectPasswordByCardId(card.getCardId());
|
|
|
|
|
+ if (StringUtils.isNotEmpty(dbPwd)){
|
|
|
|
|
+ password = dbPwd;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
// 用户验证
|
|
// 用户验证
|
|
|
Authentication authentication = null;
|
|
Authentication authentication = null;
|
|
@@ -170,7 +194,7 @@ public class SysLoginService
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 校验验证码
|
|
* 校验验证码
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @param username 用户名
|
|
* @param username 用户名
|
|
|
* @param code 验证码
|
|
* @param code 验证码
|
|
|
* @param uuid 唯一标识
|
|
* @param uuid 唯一标识
|