@@ -41,32 +41,31 @@ public HttpResponse<HasPermissionResponse> hasPermission(@Body HasPermissionRequ
41
41
42
42
Optional <Tenant > tenantOptional = tenantRepo .findById (requestDTO .tenantId ());
43
43
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 ());
45
45
}
46
46
47
47
User user = userRepo .findByEmail (authentication .getName ()).orElse (null );
48
48
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 ());
50
50
}
51
51
52
52
Optional <Service > service = serviceRepo .findById (requestDTO .serviceId ());
53
53
54
54
String serviceStatusCheckResult = checkServiceStatus (service );
55
55
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 ());
57
57
}
58
58
59
59
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 ());
62
61
}
63
62
64
63
List <String > commonPermissions = checkUserPermission (user , tenantOptional .get (), requestDTO .permissions ());
65
64
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 );
67
66
}
68
67
69
- return createHasPermissionResponse (true , user .getEmail (), user . getFirstName (), user . getLastName (), null , commonPermissions );
68
+ return createHasPermissionResponse (true , user .getEmail (), null , commonPermissions );
70
69
}
71
70
72
71
private boolean checkUserStatus (User user ) {
@@ -105,19 +104,15 @@ private List<String> checkUserPermission(User user, Tenant tenant, List<String>
105
104
106
105
private HttpResponse <HasPermissionResponse > createHasPermissionResponse (boolean hasPermission ,
107
106
String userEmail ,
108
- String firstName ,
109
- String lastName ,
110
107
String message ,
111
108
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 ));
113
110
}
114
111
115
112
@ Serdeable
116
113
public record HasPermissionResponse (
117
114
boolean hasPermission ,
118
115
@ Nullable String userEmail ,
119
- @ Nullable String firstName ,
120
- @ Nullable String lastName ,
121
116
@ Nullable String errorMessage ,
122
117
List <String > permissions
123
118
) {
0 commit comments