Skip to content

Commit

Permalink
admin role fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
OSousa117 committed Oct 31, 2023
1 parent 51980f2 commit b4e4dfc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.auth0.jwt.JWT;
import com.auth0.jwt.interfaces.Claim;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.fasterxml.uuid.Logger;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.IntrospectTokenResponse;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.Role;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.TokenResponse;
Expand Down Expand Up @@ -230,19 +231,17 @@ private UserEntity generateUser(String userID, DecodedJWT decodedJWT) {

Object rolesObject = realmAccessMap.get("roles");

if (rolesObject instanceof List<?>) {
List<?> list = (List<?>) rolesObject;
if (rolesObject instanceof List<?> list) {
for (Object roleObj : list) {
if (roleObj instanceof String) {
String roleStr = (String) roleObj;
if (roleObj instanceof String roleStr) {
try {
org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.Role role = org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.Role.valueOf(
roleStr
);
newUserEntity.setRole(role);
break;
} catch (IllegalArgumentException e) {
throw new RuntimeException("Illegal Role detected! User must have one of the role types");
Logger.logError("Incompatible role! User must have one of the 3 role types 'ADMIN','CUSTOMER','SUPPLIER'");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ components:
enum:
- CUSTOMER
- SUPPLIER
- ADMIN
TokenResponse:
type: object
properties:
Expand Down

0 comments on commit b4e4dfc

Please sign in to comment.