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

Username can be updated in configuration #1204

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Thendo20
Copy link
Collaborator

What this PR does / why we need it:

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

PR Readiness Checklist:

Complete these before marking the PR as ready to review:

  • the CHANGELOG.md release notes have been updated to reflect any significant (and particularly user-facing) changes introduced by this PR

@Thendo20 Thendo20 self-assigned this Nov 20, 2024
@Thendo20 Thendo20 linked an issue Nov 20, 2024 that may be closed by this pull request
Copy link

sonarqubecloud bot commented Jan 7, 2025

@@ -278,7 +278,7 @@ jobs:

- uses: actions/[email protected]
with:
python-version: 3.7
python-version: 3.9
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi thendo please bump the python-version to 3.9 to Sync with the main.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @AssahBismarkabah, okay will do

@@ -59,11 +59,28 @@ public Optional<UserRepresentation> search(String realmName, String username) {
return user;
}

public Optional<UserRepresentation> searchByEmail(String realmName, String email) {
UsersResource usersResource = realmRepository.getResource(realmName).users();
List<UserRepresentation> foundUsers = usersResource.search(email, 0, 50);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are more than 50 users in the realm, and the user with the matching email is not among the first 50 results returned by the search, the search will fail to find the user, even if they exist. To ensure the user is located, you could search among all users.

public Optional<UserRepresentation> searchByEmail(String realmName, String email) {
    UsersResource usersResource = realmRepository.getResource(realmName).users();
    List<UserRepresentation> foundUsers = usersResource.searchByEmail(email, true);

    return foundUsers.isEmpty() ? Optional.empty() : Optional.of(foundUsers.get(0));
}

Copy link
Collaborator Author

@Thendo20 Thendo20 Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh okay, I thought the search function will look through all the users then returns 50 or less elements/users that have a partial match to the email that you're looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Let user username be updated in config
2 participants