liurunyu
昨天 f44135f835bf62319f9bb8a32e4592a707e5e8c1
pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java
@@ -116,39 +116,31 @@
        //把组织单位标签作为数据源名称
        DataSourceContext.set(vo.orgTag);
        String token = Optional.ofNullable(vo.getToken()).orElse("");
        String code = Optional.ofNullable(vo.getCode()).orElse("");
        if(token.length() > 0 && code.length() > 0) {
        if(vo.token != null && vo.token.trim().length() > 0) {
            // 从session中获取验证码
            //HttpSession session = (HttpSession) request.getSession();
            //String localCode = session.getAttribute(token).toString();
            Map map = sv.getCodeByToken(token);
            // 从数据库获取验证码
            Map map = sv.getCodeByToken(vo.token);
            Long expiration = Long.parseLong(map.get("expiration").toString());
            Long currentTimestamp = System.currentTimeMillis();
            if(currentTimestamp > expiration) {
                return BaseResponseUtils.buildErrorMsg("验证码已超时");
            }
            // 从数据库获取验证码
            String localCode = map.get("code").toString();
            if(!code.equals(localCode)) {
            if(!vo.code.equals(localCode)) {
                return BaseResponseUtils.buildErrorMsg("验证码错误");
            }
        }
        //得到所有用户账号
        List<String> phones = sv.getPhones();
        if(!phones.contains(vo.phone)){
        if(!sv.existPhone(vo.phone)){
            return BaseResponseUtils.buildErrorMsg("账号不存在");
        }
        String uuid ;
        BaUser userPo ;
        String uuid4Token = null;
        BaUser userPo = null ;
        try {
            //Boolean flag = cacheManager.getCacheNames().isEmpty() ;
            uuid = UUID.randomUUID().toString();
            uuid4Token = UUID.randomUUID().toString();
            if(!StringUtils.isNullOrEmpty(vo.password)){
                /*
                如果前端进行了base64加密
@@ -156,7 +148,7 @@
                */
                vo.password = MD5.encrypt(vo.password) ;
            }
            userPo = this.sv.loginWithMapperXml(uuid, vo.phone, vo.password);
            userPo = this.sv.loginWithMapperXml(uuid4Token, vo.phone, vo.password);
        } catch (Exception e) {
            log.error("用户登录异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
@@ -164,10 +156,10 @@
        if(userPo != null){
            UserVo uVo = UserVoMapper.INSTANCT.po2vo(userPo);
            uVo.token = uuid ;
            uVo.token = uuid4Token ;
            return BaseResponseUtils.buildSuccess(uVo);
        }else{
            return BaseResponseUtils.buildErrorMsg("密码错误");
            return BaseResponseUtils.buildErrorMsg("登录失败");
        }
    }