LAPTOP-KB9HII50\70708 il y a 1 an
Parent
commit
4db5a25e2f

+ 1 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -621,7 +621,7 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        if (StringUtils.isBlank(loginType) || "1".equals(loginType)) { //1或默认查找user表,为平台管理员账号
        if (StringUtils.isBlank(loginType) || "1".equals(loginType)) { //1或默认查找user表,为平台管理员账号
            result = this.getJdbcTemplate().queryForMap("select u.login_failure_count,u.last_login_failure_time from base_user u where u.username = ? or u.mobile = ? or u.idcard = ?", username, username, username);
            result = this.getJdbcTemplate().queryForMap("select u.login_failure_count,u.last_login_failure_time from base_user u where u.username = ? or u.mobile = ? or u.idcard = ?", username, username, username);
        } else if ("2".equals(loginType)) {//2.为医生账号
        } else if ("2".equals(loginType)) {//2.为医生账号
            result = this.getJdbcTemplate().queryForMap("select d.login_failure_count,d.last_login_failure_time from base_doctor d where d.mobile = ? or d.idcard = ?", username, username);
            result = this.getJdbcTemplate().queryForMap("select d.login_failure_count,d.last_login_failure_time from base_doctor d where d.mobile = ? or d.idcard = ? and d.del='1' limit 1", username, username);
        } else if ("3".equals(loginType)) { //3.患者账号
        } else if ("3".equals(loginType)) { //3.患者账号
            result = this.getJdbcTemplate().queryForMap("select p.login_failure_count,p.last_login_failure_time from base_patient p where p.mobile = ? or p.idcard = ? limit 1", username, username);
            result = this.getJdbcTemplate().queryForMap("select p.login_failure_count,p.last_login_failure_time from base_patient p where p.mobile = ? or p.idcard = ? limit 1", username, username);
        } else if ("4".equals(loginType)) { //4.第三方患者账号
        } else if ("4".equals(loginType)) { //4.第三方患者账号

+ 14 - 12
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/WlyyTokenGranter.java

@ -705,23 +705,25 @@ public class WlyyTokenGranter implements TokenGranter {
                throw new InvalidGrantException("Invalid captcha");
                throw new InvalidGrantException("Invalid captcha");
            }
            }
            String password = parameters.get("password");
            String password = parameters.get("password");
            parameters.remove("password");
//            parameters.remove("password");
            Authentication userAuth = new UsernamePasswordAuthenticationToken(username, password);
            ((AbstractAuthenticationToken) userAuth).setDetails(parameters);
            try {
                userAuth = authenticationManager.authenticate(userAuth);
            SaltUser userDetails = (SaltUser)userDetailsService.loadUserByUsername(username);
            if(userDetails==null){
                throw new InvalidGrantException("Could not authenticate user: " + username);
            }
            }
            catch (AccountStatusException ase) {
                throw new InvalidGrantException(ase.getMessage());
            String pwd = MD5.md5Hex(password+ "{" + userDetails.getSalt() + "}");
            if(!pwd.equals(userDetails.getPassword())){
                throw new InvalidGrantException("Bad credentials");
            }
            }
            catch (BadCredentialsException e) {
                throw new InvalidGrantException(e.getMessage());
            if (!userDetails.isEnabled()) {
                throw new InvalidGrantException("User is disabled");
            }
            }
            if (userAuth == null || !userAuth.isAuthenticated()) {
                throw new InvalidGrantException("Could not authenticate user: " + username);
            if (!userDetails.isAccountNonLocked()) {
                throw new InvalidGrantException("User account is locked");
            }
            }
            Authentication userAuth = new UsernamePasswordAuthenticationToken(username,userDetails.getPassword(),  this.authoritiesMapper.mapAuthorities(userDetails.getAuthorities()));
            ((AbstractAuthenticationToken) userAuth).setDetails(parameters);
            OAuth2Request storedOAuth2Request = getRequestFactory().createOAuth2Request(client, tokenRequest);
            OAuth2Request storedOAuth2Request = getRequestFactory().createOAuth2Request(client, tokenRequest);
            return new OAuth2Authentication(storedOAuth2Request, userAuth);
            return new OAuth2Authentication(storedOAuth2Request, userAuth);
        }
        }