...
|
...
|
@@ -51,19 +51,24 @@ public class MyAuthenticationSuccessHandler extends SavedRequestAwareAuthenticat |
|
|
if (LoginType.JSON.equals(securityProperties.getBrowser().getLoginType())){
|
|
|
//将 authention 信息打包成json格式返回
|
|
|
response.setContentType("application/json;charset=UTF-8");
|
|
|
response.setHeader("Access-Control-Allow-Origin","*");
|
|
|
// response.setHeader("Access-Control-Allow-Origin","*");
|
|
|
|
|
|
|
|
|
USERS loginedUser = (USERS) authentication.getPrincipal();
|
|
|
//返回前端的数据安全起见把password去掉
|
|
|
loginedUser.setPassword(null);
|
|
|
USERS user = (USERS) authentication.getPrincipal();
|
|
|
|
|
|
//设置用户的TOKEN的有效时间,下面是300秒=5分钟
|
|
|
//返回前端登陆成功后的用户信息
|
|
|
USERS loginedUser = new USERS();
|
|
|
loginedUser.setUsername(user.getUsername());
|
|
|
loginedUser.setUserface(user.getUserface());
|
|
|
|
|
|
|
|
|
//设置用户的TOKEN的有效时间,时间配置在配置文件中设置
|
|
|
String jwtToken = JwtTokenUtil.generateToken(loginedUser.getUsername(), jwtMaxAlive);
|
|
|
response.setHeader("Authorization",jwtToken);
|
|
|
loginedUser.setToken(jwtToken);
|
|
|
|
|
|
Map<String,Object> menuMap = permissionService.getUserMenus(loginedUser.getUserId());
|
|
|
response.getWriter().write(objectMapper.writeValueAsString(new AuthSuccessResponse(authentication,menuMap)));
|
|
|
Map<String,Object> menuMap = permissionService.getUserMenus(user.getUserId());
|
|
|
//返回用户信息和用户可访问的目录列表
|
|
|
response.getWriter().write(objectMapper.writeValueAsString(new AuthSuccessResponse(loginedUser,menuMap)));
|
|
|
}else {
|
|
|
//走原来的处理流程
|
|
|
SavedRequest savedRequest = this.requestCache.getRequest(request, response);
|
...
|
...
|
|