|
@ -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());
|