| | |
| | | import com.ltkj.framework.manager.AsyncManager; |
| | | import com.ltkj.framework.manager.factory.AsyncFactory; |
| | | import com.ltkj.framework.security.context.AuthenticationContextHolder; |
| | | import org.springframework.util.DigestUtils; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | |
| | | public String login(String username, String password, Boolean type,String code,String uuid) { |
| | | |
| | | String aSwitch = configService.selectConfigByKey("captcha_switch"); |
| | | if(null !=aSwitch && aSwitch.equals("Y")){ |
| | | if(null !=aSwitch && aSwitch.equalsIgnoreCase("Y")){ |
| | | String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid; |
| | | String captcha = redisCache.getCacheObject(verifyKey); |
| | | redisCache.deleteObject(verifyKey); |
| | |
| | | try { |
| | | //登录密码解密 |
| | | String s = RsaUtils.decryptByPrivateKey(password); |
| | | // String s = password; |
| | | if(username.equals("10001")){ |
| | | s=username+s; |
| | | } |
| | |
| | | * @param password 密码 |
| | | * @return 结果 |
| | | */ |
| | | public String Cuslogin(String username, String password, Boolean type,String code,String uuid) { |
| | | public String Cuslogin(String username,String sfzh, String password, Boolean type,String code,String uuid) { |
| | | |
| | | String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid; |
| | | String captcha = redisCache.getCacheObject(verifyKey); |
| | | redisCache.deleteObject(verifyKey); |
| | | if (captcha == null) |
| | | { |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"))); |
| | | throw new CaptchaExpireException(); |
| | | String aSwitch = configService.selectConfigByKey("captcha_switch"); |
| | | if(null !=aSwitch && aSwitch.equalsIgnoreCase("Y")){ |
| | | String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid; |
| | | String captcha = redisCache.getCacheObject(verifyKey); |
| | | redisCache.deleteObject(verifyKey); |
| | | if (captcha == null) |
| | | { |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"))); |
| | | throw new CaptchaExpireException(); |
| | | } |
| | | if (!code.equalsIgnoreCase(captcha)) |
| | | { |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"))); |
| | | throw new CaptchaException(); |
| | | } |
| | | } |
| | | if (!code.equalsIgnoreCase(captcha)) |
| | | { |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"))); |
| | | throw new CaptchaException(); |
| | | } |
| | | LoginUser loginUser = loadCusByCusname(username, password); |
| | | |
| | | |
| | | LoginUser loginUser = loadCusByCusname(username,sfzh, password); |
| | | if (loginUser == null) { |
| | | return "用户名或密码错误"; |
| | | return null; |
| | | } |
| | | // 限制账户不允许多终端登录 |
| | | if (!soloLogin) { |
| | |
| | | return tokenService.createToken(loginUser); |
| | | } |
| | | |
| | | public LoginUser loadCusByCusname(String username, String password) { |
| | | public LoginUser loadCusByCusname(String username,String sfzh, String password) { |
| | | LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>(); |
| | | wq.eq(TjCustomer::getCusPhone, username); |
| | | wq.eq(TjCustomer::getCusIdcard, sfzh); |
| | | List<TjCustomer> customerList = customerService.list(wq); |
| | | if (null == customerList || customerList.size() == 0) { |
| | | if (null == customerList || customerList.isEmpty()) { |
| | | //throw new ServiceException("登录用户:" + username + " 不存在"); |
| | | throw new ServiceException("账户或密码错误,请检查!"); |
| | | throw new ServiceException("账号或密码错误,请检查!"); |
| | | } |
| | | for (TjCustomer tjCustomer : customerList) { |
| | | try { |
| | | password = RsaUtils.decryptByPrivateKey(password); |
| | | boolean b = SecurityUtils.matchesPassword(password, tjCustomer.getCusPassword()); |
| | | if (b) { |
| | | // password = RsaUtils.decryptByPrivateKey(password); |
| | | // boolean b = SecurityUtils.matchesPassword(password, tjCustomer.getCusPassword()); |
| | | // if (b) { |
| | | // return createLoginCus(tjCustomer); |
| | | // } |
| | | password = DigestUtils.md5DigestAsHex(password.getBytes()); |
| | | if (password.equals(tjCustomer.getCusPassword())){ |
| | | return createLoginCus(tjCustomer); |
| | | } |
| | | } catch (Exception e) { |