Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos and readability on PR 1570 #1588

Closed
RMCampos opened this issue Aug 30, 2024 · 0 comments · Fixed by #1658
Closed

Fix typos and readability on PR 1570 #1588

RMCampos opened this issue Aug 30, 2024 · 0 comments · Fixed by #1658
Assignees
Labels
bug Something isn't working middle-sprint Issues added after the beginning of the sprint

Comments

@RMCampos
Copy link
Contributor

RMCampos commented Aug 30, 2024

User Story

As a user, I want to have no typos and easy to read code, when possible.

Acceptance Criteria

  • Fix MINITRY_OF_FORESTS_ID typo in the config.Constants class;
  • Change current implementation making easier to understand.

Additional Notes

Suggestion:

public static List<String> getClientIdsFromJwt(Jwt jwtPrincipal) {
  List<String> clientIds = new ArrayList<>();
  boolean foundRole = false;
  
  List<String> rolesAndClientIds = getRolesWithClientIds(jwtPrincipal);
  for (String role: rolesAndClientIds) {
    if (role.length() >= 9) {
      String clientNumber = role.substring(role.length() - 8);
      if (clientNumber.replaceAll("[0-9]", "").isEmpty()) {
        clientIds.add(clientNumber);
      }
    }

    if (concreteRoles.contains(role)) {
      foundRole = true;
    }
  }

  // If has role SPAR_MINISTRY_ORCHARD or SPAR_TSC_ADMIN and has no client id
  // then add MOF client id
  if (foundRole && !clientIds.contains(Constants.MINITRY_OF_FORESTS_ID)) {
    clientIds.add(Constants.MINITRY_OF_FORESTS_ID);
  }

  return clientIds;
}
@RMCampos RMCampos converted this from a draft issue Aug 30, 2024
@RMCampos RMCampos added the bug Something isn't working label Aug 30, 2024
@RMCampos RMCampos self-assigned this Sep 16, 2024
@mgaseta mgaseta added the middle-sprint Issues added after the beginning of the sprint label Sep 17, 2024
RMCampos pushed a commit that referenced this issue Oct 3, 2024
@RMCampos RMCampos linked a pull request Oct 3, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working middle-sprint Issues added after the beginning of the sprint
2 participants