Skip to content

Commit 7d905df

Browse files
committed
Undo adding of first and last name in hasPermission response
Signed-off-by: montesm <[email protected]>
1 parent b03c25a commit 7d905df

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

UnityAuth/src/main/java/io/unityfoundation/auth/AuthController.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,31 @@ public HttpResponse<HasPermissionResponse> hasPermission(@Body HasPermissionRequ
4141

4242
Optional<Tenant> tenantOptional = tenantRepo.findById(requestDTO.tenantId());
4343
if (tenantOptional.isEmpty()) {
44-
return createHasPermissionResponse(false, authentication.getName(),null, null, "Cannot find tenant!", List.of());
44+
return createHasPermissionResponse(false, authentication.getName(),"Cannot find tenant!", List.of());
4545
}
4646

4747
User user = userRepo.findByEmail(authentication.getName()).orElse(null);
4848
if (checkUserStatus(user)) {
49-
return createHasPermissionResponse(false, authentication.getName(), null, null, "The user’s account has been disabled!", List.of());
49+
return createHasPermissionResponse(false, authentication.getName(), "The user’s account has been disabled!", List.of());
5050
}
5151

5252
Optional<Service> service = serviceRepo.findById(requestDTO.serviceId());
5353

5454
String serviceStatusCheckResult = checkServiceStatus(service);
5555
if (serviceStatusCheckResult != null) {
56-
return createHasPermissionResponse(false, user.getEmail(), user.getFirstName(), user.getLastName(), serviceStatusCheckResult, List.of());
56+
return createHasPermissionResponse(false, user.getEmail(), serviceStatusCheckResult, List.of());
5757
}
5858

5959
if (!userRepo.isServiceAvailable(user.getId(), service.get().getId())) {
60-
return createHasPermissionResponse(false, user.getEmail(), user.getFirstName(), user.getLastName(),
61-
"The requested service is not enabled for the requested tenant!", List.of());
60+
return createHasPermissionResponse(false, user.getEmail(), "The requested service is not enabled for the requested tenant!", List.of());
6261
}
6362

6463
List<String> commonPermissions = checkUserPermission(user, tenantOptional.get(), requestDTO.permissions());
6564
if (commonPermissions.isEmpty()) {
66-
return createHasPermissionResponse(false, user.getEmail(), user.getFirstName(), user.getLastName(), "The user does not have permission!", commonPermissions);
65+
return createHasPermissionResponse(false, user.getEmail(), "The user does not have permission!", commonPermissions);
6766
}
6867

69-
return createHasPermissionResponse(true, user.getEmail(), user.getFirstName(), user.getLastName(), null, commonPermissions);
68+
return createHasPermissionResponse(true, user.getEmail(), null, commonPermissions);
7069
}
7170

7271
private boolean checkUserStatus(User user) {
@@ -105,19 +104,15 @@ private List<String> checkUserPermission(User user, Tenant tenant, List<String>
105104

106105
private HttpResponse<HasPermissionResponse> createHasPermissionResponse(boolean hasPermission,
107106
String userEmail,
108-
String firstName,
109-
String lastName,
110107
String message,
111108
List<String> permissions) {
112-
return HttpResponse.ok(new HasPermissionResponse(hasPermission, userEmail, firstName, lastName, message, permissions));
109+
return HttpResponse.ok(new HasPermissionResponse(hasPermission, userEmail, message, permissions));
113110
}
114111

115112
@Serdeable
116113
public record HasPermissionResponse(
117114
boolean hasPermission,
118115
@Nullable String userEmail,
119-
@Nullable String firstName,
120-
@Nullable String lastName,
121116
@Nullable String errorMessage,
122117
List<String> permissions
123118
) {

UnityAuth/src/test/java/io/unityfoundation/UnityIamTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ void testHasSystemPermission() {
4949
assertEquals(Boolean.TRUE, response.getBody().get().hasPermission());
5050
assertEquals("[email protected]", response.getBody().get().userEmail());
5151
assertTrue(response.getBody().get().permissions().contains("AUTH_SERVICE_EDIT-SYSTEM"));
52-
assertEquals("Person", response.getBody().get().firstName());
53-
assertEquals("One", response.getBody().get().lastName());
5452
}
5553

5654
@Test

0 commit comments

Comments
 (0)