|
@ -147,11 +147,11 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
在网关处通过HTTP状态码告知前端是过期(402)还是账号在别处登陆(403),
|
|
在网关处通过HTTP状态码告知前端是过期(402)还是账号在别处登陆(403),
|
|
实现同一账号只能在一处登陆*/
|
|
实现同一账号只能在一处登陆*/
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
if (request.getHeader("login-device") != null && request.getHeader("login-device").equals("mobile")) {
|
|
|
|
tokenStore.removeAccessToken(token.getValue());
|
|
|
|
tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
|
|
|
|
token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
|
|
|
|
}
|
|
|
|
|
|
// if (request.getHeader("login-device") != null && request.getHeader("login-device").equals("mobile")) {
|
|
|
|
tokenStore.removeAccessToken(token.getValue());
|
|
|
|
tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
|
|
|
|
token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
|
|
|
|
// }
|
|
if (token == null) {
|
|
if (token == null) {
|
|
throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
|
|
throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
|
|
}
|
|
}
|
|
@ -240,8 +240,11 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
}
|
|
}
|
|
String userAgent = loginLog.getUserAgent();
|
|
String userAgent = loginLog.getUserAgent();
|
|
WlyyUserSimple wlyyUserSimple = JSONObject.parseObject(userAgent, WlyyUserSimple.class);
|
|
WlyyUserSimple wlyyUserSimple = JSONObject.parseObject(userAgent, WlyyUserSimple.class);
|
|
// String accessToken = wlyyUserSimple.getAccessToken();
|
|
|
|
// OAuth2AccessToken oAuth2AccessToken = tokenStore.readAccessToken(accessToken);
|
|
|
|
|
|
String accessToken = wlyyUserSimple.getAccessToken();
|
|
|
|
OAuth2Authentication authentication = tokenStore.readAuthentication(accessToken);
|
|
|
|
if (null == authentication) {
|
|
|
|
throw new InvalidTokenException("Cant not load authentication");
|
|
|
|
}
|
|
return getResponse(wlyyUserSimple);
|
|
return getResponse(wlyyUserSimple);
|
|
}
|
|
}
|
|
|
|
|
|
@ -557,7 +560,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
|
|
} else if (e instanceof InvalidGrantException) {
|
|
} else if (e instanceof InvalidGrantException) {
|
|
return handleOAuth2Exception(new Oauth2Envelop(invalidGrantMessage((InvalidGrantException)e), HttpStatus.UNAUTHORIZED.value()), e);
|
|
return handleOAuth2Exception(new Oauth2Envelop(invalidGrantMessage((InvalidGrantException)e), HttpStatus.UNAUTHORIZED.value()), e);
|
|
} else if (e instanceof InvalidTokenException) {
|
|
} else if (e instanceof InvalidTokenException) {
|
|
return handleOAuth2Exception(new Oauth2Envelop("Token有误!", HttpStatus.UNAUTHORIZED.value()), e);
|
|
|
|
|
|
return handleOAuth2Exception(new Oauth2Envelop("Token有误/过期!", HttpStatus.FORBIDDEN.value()), e);
|
|
} else if (e instanceof InvalidRequestException) {
|
|
} else if (e instanceof InvalidRequestException) {
|
|
return handleOAuth2Exception(new Oauth2Envelop("参数" + e.getMessage() + "缺失!", HttpStatus.UNAUTHORIZED.value()), e);
|
|
return handleOAuth2Exception(new Oauth2Envelop("参数" + e.getMessage() + "缺失!", HttpStatus.UNAUTHORIZED.value()), e);
|
|
} else if (e instanceof IllegalAccessException) {
|
|
} else if (e instanceof IllegalAccessException) {
|