Browse Source

token增加postId

test
smallchill 5 years ago
parent
commit
bd6bde7aa3
  1. 7
      blade-auth/src/main/java/org/springblade/auth/service/BladeUserDetails.java
  2. 2
      blade-auth/src/main/java/org/springblade/auth/service/BladeUserDetailsServiceImpl.java
  3. 1
      blade-auth/src/main/java/org/springblade/auth/support/BladeJwtTokenEnhancer.java
  4. 1
      blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java

7
blade-auth/src/main/java/org/springblade/auth/service/BladeUserDetails.java

@ -54,6 +54,10 @@ public class BladeUserDetails extends User {
* 部门id
*/
private String deptId;
/**
* 岗位id
*/
private String postId;
/**
* 角色id
*/
@ -67,7 +71,7 @@ public class BladeUserDetails extends User {
*/
private String avatar;
public BladeUserDetails(Long userId, String tenantId, String name, String realName, String deptId, String roleId, String roleName, String avatar, String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) {
public BladeUserDetails(Long userId, String tenantId, String name, String realName, String deptId, String postId, String roleId, String roleName, String avatar, String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) {
super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
this.userId = userId;
this.tenantId = tenantId;
@ -75,6 +79,7 @@ public class BladeUserDetails extends User {
this.realName = realName;
this.account = username;
this.deptId = deptId;
this.postId = postId;
this.roleId = roleId;
this.roleName = roleName;
this.avatar = avatar;

2
blade-auth/src/main/java/org/springblade/auth/service/BladeUserDetailsServiceImpl.java

@ -98,7 +98,7 @@ public class BladeUserDetailsServiceImpl implements UserDetailsService {
throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_ROLE);
}
return new BladeUserDetails(user.getId(),
user.getTenantId(), user.getName(), user.getRealName(), user.getDeptId(), user.getRoleId(), Func.join(result.getData().getRoles()), Func.toStr(user.getAvatar(), TokenUtil.DEFAULT_AVATAR),
user.getTenantId(), user.getName(), user.getRealName(), user.getDeptId(), user.getPostId(),user.getRoleId(), Func.join(result.getData().getRoles()), Func.toStr(user.getAvatar(), TokenUtil.DEFAULT_AVATAR),
username, AuthConstant.ENCRYPT + user.getPassword(), true, true, true, true,
AuthorityUtils.commaSeparatedStringToAuthorityList(Func.join(result.getData().getRoles())));
} else {

1
blade-auth/src/main/java/org/springblade/auth/support/BladeJwtTokenEnhancer.java

@ -40,6 +40,7 @@ public class BladeJwtTokenEnhancer implements TokenEnhancer {
info.put(TokenUtil.CLIENT_ID, TokenUtil.getClientIdFromHeader());
info.put(TokenUtil.USER_ID, Func.toStr(principal.getUserId()));
info.put(TokenUtil.DEPT_ID, Func.toStr(principal.getDeptId()));
info.put(TokenUtil.POST_ID, Func.toStr(principal.getPostId()));
info.put(TokenUtil.ROLE_ID, Func.toStr(principal.getRoleId()));
info.put(TokenUtil.TENANT_ID, principal.getTenantId());
info.put(TokenUtil.ACCOUNT, principal.getAccount());

1
blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java

@ -43,6 +43,7 @@ public class TokenUtil {
public final static String REAL_NAME = TokenConstant.REAL_NAME;
public final static String USER_ID = TokenConstant.USER_ID;
public final static String DEPT_ID = TokenConstant.DEPT_ID;
public final static String POST_ID = TokenConstant.POST_ID;
public final static String ROLE_ID = TokenConstant.ROLE_ID;
public final static String ROLE_NAME = TokenConstant.ROLE_NAME;
public final static String TENANT_ID = TokenConstant.TENANT_ID;

Loading…
Cancel
Save