添加新特性。 jwt token 支持获取用户ID

This commit is contained in:
冷冷 2018-07-01 22:31:45 +08:00
parent 4f82d4801f
commit b1f710ad87
3 changed files with 2 additions and 4 deletions

View File

@ -138,7 +138,7 @@ public class PigAuthorizationConfig extends AuthorizationServerConfigurerAdapter
final Map<String, Object> additionalInfo = new HashMap<>(2);
additionalInfo.put("license", SecurityConstants.PIG_LICENSE);
UserDetailsImpl user = (UserDetailsImpl) authentication.getUserAuthentication().getPrincipal();
if(user!=null) {
if (user != null) {
additionalInfo.put("userId", user.getUserId());
}
((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(additionalInfo);

View File

@ -43,7 +43,7 @@ public class UserDetailsImpl implements UserDetails {
private List<SysRole> roleList;
public UserDetailsImpl(UserVO userVo) {
this.userId=userVo.getUserId();
this.userId = userVo.getUserId();
this.username = userVo.getUsername();
this.password = userVo.getPassword();
this.status = userVo.getDelFlag();

View File

@ -23,8 +23,6 @@ import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import javax.servlet.http.HttpServletRequest;