这个问题我也想问,如果是这样会不会开发运维成本太大了,这两个模块不能整合么? 如:认证成功处理器,根据比如spring-mobile类似判断渠道的方式进行不同的资源数据输出:
```java
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
L.info("身份认证(登录)成功");
final SavedRequest savedRequest = requestCache.getRequest(request, response);
if (savedRequest != null) {
final Device currentDevice = HttpUtils.resolveDevice(savedRequest.getHeaderValues("user-agent").get(0), savedRequest.getHeaderValues("accept").get(0));
// 根据渠道返回不同的响应数据
// 还有一种做法是根据客户端程序配置来指定响应数据格式:https://coding.imooc.com/lesson/134.html#mid=6866
if (!currentDevice.isNormal()) {
response.setContentType("application/json;charset=UTF-8");
// 将authentication转换成json str输出
response.getWriter().write(objectMapper.writeValueAsString(authentication));
} else {
// 默认是做重定向到登录之前的【期望访问资源】接口
super.onAuthenticationSuccess(request, response, authentication);
}
} else {
// 默认是做重定向到登录之前的【期望访问资源】接口
super.onAuthenticationSuccess(request, response, authentication);
}
}
```