...
|
...
|
@@ -2,8 +2,6 @@ package com.tianbo.warehouse.security.handel; |
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.tianbo.warehouse.bean.AuthSuccessResponse;
|
|
|
import com.tianbo.warehouse.controller.PermssionController;
|
|
|
import com.tianbo.warehouse.model.PERMISSION;
|
|
|
import com.tianbo.warehouse.model.USERS;
|
|
|
import com.tianbo.warehouse.security.filter.JwtTokenUtil;
|
|
|
import com.tianbo.warehouse.security.model.LoginType;
|
...
|
...
|
@@ -12,8 +10,8 @@ import org.apache.commons.logging.Log; |
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import com.tianbo.warehouse.security.config.SecurityProperties;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.security.core.Authentication;
|
|
|
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
|
|
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
|
|
|
import org.springframework.security.web.savedrequest.HttpSessionRequestCache;
|
|
|
import org.springframework.security.web.savedrequest.RequestCache;
|
...
|
...
|
@@ -34,6 +32,9 @@ import java.util.Map; |
|
|
public class MyAuthenticationSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler{
|
|
|
protected final Log logger = LogFactory.getLog(this.getClass());
|
|
|
|
|
|
@Value("${jwt.max-alive}")
|
|
|
protected Integer jwtMaxAlive;
|
|
|
|
|
|
@Autowired
|
|
|
private ObjectMapper objectMapper;
|
|
|
|
...
|
...
|
@@ -58,7 +59,7 @@ public class MyAuthenticationSuccessHandler extends SavedRequestAwareAuthenticat |
|
|
loginedUser.setPassword(null);
|
|
|
|
|
|
//设置用户的TOKEN的有效时间,下面是300秒=5分钟
|
|
|
String jwtToken = JwtTokenUtil.generateToken(loginedUser.getUsername(), 300);
|
|
|
String jwtToken = JwtTokenUtil.generateToken(loginedUser.getUsername(), jwtMaxAlive);
|
|
|
response.setHeader("Authorization",jwtToken);
|
|
|
|
|
|
Map<String,Object> menuMap = permissionService.getUserMenus(loginedUser.getUserId());
|
...
|
...
|
|