Explorar el Código

Merge branch 'dev' of yeshijie/wlyy2.0 into dev

叶仕杰 hace 3 años
padre
commit
4b8dbecd4a

+ 13 - 8
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -154,6 +154,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    private BaseDoctorDao doctorDao;
    @Value("${wechat.id}")
    private String wechatId;
    @Value("${kick.eachOther}")
    private String kickEachOther;
    @Autowired
    private XzzxService xzzxService;
    @Autowired
@ -337,15 +339,18 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        /*如果是移动端登陆则移除之前的token,
        在网关处通过HTTP状态码告知前端是过期(402)还是账号在别处登陆(403),
        实现同一账号只能在一处登陆*/
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        if (request.getHeader("login-device") != null && (request.getHeader("login-device").equalsIgnoreCase("mobile")||request.getHeader("login-device").equalsIgnoreCase("pc"))) {
            tokenStore.removeAccessToken(token.getValue());
            tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
            token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
        }
        if (token == null) {
            throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
        if("1".equals(kickEachOther)){
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            if (request.getHeader("login-device") != null && (request.getHeader("login-device").equalsIgnoreCase("mobile")||request.getHeader("login-device").equalsIgnoreCase("pc"))) {
                tokenStore.removeAccessToken(token.getValue());
                tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
                token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
            }
            if (token == null) {
                throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
            }
        }
        WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
        wlyyUserSimple.setAccessToken(token.getValue());
        wlyyUserSimple.setTokenType(token.getTokenType());

+ 7 - 0
server/svr-authentication/src/main/resources/application.yml

@ -53,6 +53,10 @@ fast-dfs:
    init-size: 5
    max-size: 20
    wait-time: 500
kick:
    ##互踢 1开通 0关闭
    eachOther: 1
---
spring:
  profiles: jwdev
@ -406,6 +410,9 @@ testPattern:
wechat:
  id: hz_yyyzh_wx  # base库中,wx_wechat 的id字段
kick:
    ##互踢 1开通 0关闭
    eachOther: 0
---
spring:
  profiles: wjwProd