fix: bind overseas receiving to shared warehouse
This commit is contained in:
@@ -9,11 +9,19 @@ import java.util.Set;
|
||||
public record AuthenticatedUser(Long userId, Long tenantId, Long operatorTenantId, Long membershipId,
|
||||
String username, String appCode, String clientType,
|
||||
Set<String> permissions, boolean impersonated, Long actorUserId,
|
||||
Long actorMembershipId, boolean passwordChangeRequired) implements Principal {
|
||||
Long actorMembershipId, boolean passwordChangeRequired,
|
||||
Long overseasWarehouseId) implements Principal {
|
||||
public AuthenticatedUser(Long userId, Long tenantId, Long operatorTenantId, Long membershipId,
|
||||
String username, String appCode, String clientType, Set<String> permissions) {
|
||||
this(userId, tenantId, operatorTenantId, membershipId, username, appCode, clientType,
|
||||
permissions, false, null, null, false);
|
||||
permissions, false, null, null, false, null);
|
||||
}
|
||||
public AuthenticatedUser(Long userId, Long tenantId, Long operatorTenantId, Long membershipId,
|
||||
String username, String appCode, String clientType, Set<String> permissions,
|
||||
boolean impersonated, Long actorUserId, Long actorMembershipId,
|
||||
boolean passwordChangeRequired) {
|
||||
this(userId, tenantId, operatorTenantId, membershipId, username, appCode, clientType,
|
||||
permissions, impersonated, actorUserId, actorMembershipId, passwordChangeRequired, null);
|
||||
}
|
||||
public AuthenticatedUser {
|
||||
permissions = permissions == null ? Set.of() : Set.copyOf(permissions);
|
||||
|
||||
@@ -43,7 +43,8 @@ public class JwtClaimsMapper {
|
||||
Boolean.TRUE.equals(jwt.getClaim("impersonated")),
|
||||
longClaim(jwt, "actor_user_id"),
|
||||
longClaim(jwt, "actor_membership_id"),
|
||||
Boolean.TRUE.equals(jwt.getClaim("password_change_required")));
|
||||
Boolean.TRUE.equals(jwt.getClaim("password_change_required")),
|
||||
longClaim(jwt, "overseas_warehouse_id"));
|
||||
List<SimpleGrantedAuthority> authorities = permissions.stream()
|
||||
.map(SimpleGrantedAuthority::new).toList();
|
||||
return new BaiyueJwtAuthenticationToken(user, jwt.getTokenValue(), authorities);
|
||||
|
||||
@@ -81,6 +81,7 @@ class JwtClaimsMapperTest {
|
||||
.claim("actor_user_id", 42L)
|
||||
.claim("actor_membership_id", 43L)
|
||||
.claim("password_change_required", true)
|
||||
.claim("overseas_warehouse_id", 900L)
|
||||
.build();
|
||||
|
||||
AuthenticatedUser user = new JwtClaimsMapper().map(jwt).getPrincipal();
|
||||
@@ -88,5 +89,6 @@ class JwtClaimsMapperTest {
|
||||
assertThat(user.actorUserId()).isEqualTo(42L);
|
||||
assertThat(user.actorMembershipId()).isEqualTo(43L);
|
||||
assertThat(user.passwordChangeRequired()).isTrue();
|
||||
assertThat(user.overseasWarehouseId()).isEqualTo(900L);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user