Browse Source

🎉 token接口增加租户id传参判断

test
smallchill 5 years ago
parent
commit
972f758685
  1. 7
      blade-auth/src/main/java/org/springblade/auth/service/BladeUserDetailsServiceImpl.java
  2. 1
      blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java

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

@ -23,6 +23,7 @@ import org.springblade.auth.enums.BladeUserEnum;
import org.springblade.auth.utils.TokenUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.core.tool.utils.WebUtil;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.entity.UserInfo;
@ -51,7 +52,11 @@ public class BladeUserDetailsServiceImpl implements UserDetailsService {
public BladeUserDetails loadUserByUsername(String username) {
HttpServletRequest request = WebUtil.getRequest();
// 获取租户
String tenantId = Func.toStr(request.getHeader(TokenUtil.TENANT_HEADER_KEY), TokenUtil.DEFAULT_TENANT_ID);
String tenantId = request.getHeader(TokenUtil.TENANT_HEADER_KEY);
if (StringUtil.isBlank(tenantId)) {
throw new UserDeniedAuthorizationException(TokenUtil.TENANT_NOT_FOUND);
}
// 获取用户类型
String userType = Func.toStr(request.getHeader(TokenUtil.USER_TYPE_HEADER_KEY), TokenUtil.DEFAULT_USER_TYPE);

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

@ -51,6 +51,7 @@ public class TokenUtil {
public final static String TENANT_HEADER_KEY = "Tenant-Id";
public final static String DEFAULT_TENANT_ID = "000000";
public final static String TENANT_NOT_FOUND = "租户ID未找到";
public final static String USER_TYPE_HEADER_KEY = "User-Type";
public final static String DEFAULT_USER_TYPE = "web";
public final static String USER_NOT_FOUND = "用户名或密码错误";

Loading…
Cancel
Save