Skip to content

Commit

Permalink
Merge pull request #343 from reportportal/EPMRPP-96070-saml-uuid
Browse files Browse the repository at this point in the history
EPMRPP-96070 || Add default fields to user builder
  • Loading branch information
pbortnik authored Oct 16, 2024
2 parents 8695f65 + 8aef132 commit 3219456
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ private void updateUser(User user, UserResource userResource, GitHubClient gitHu

private User createUser(UserResource userResource, GitHubClient gitHubClient) {
User user = new User();
String login = normalizeId(userResource.getLogin());
user.setLogin(login);
user.setLogin(normalizeId(userResource.getLogin()));
user.setUuid(UUID.randomUUID());
user.setActive(Boolean.TRUE);

updateUser(user, userResource, gitHubClient);
user.setUserType(UserType.GITHUB);
user.setRole(UserRole.USER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,25 @@ private String validateEmail(String email) {

private User createNewUser(DirContextOperations ctx, Map<String, String> syncAttributes,
String email, String login) {
User newUser = new User();
newUser.setLogin(login);
User user = new User();
user.setLogin(login);
user.setUuid(UUID.randomUUID());
user.setActive(Boolean.TRUE);

String fullName = getFullName(ctx, syncAttributes);
newUser.setFullName(fullName);
user.setFullName(fullName);

checkEmail(email);
newUser.setEmail(email);
newUser.setMetadata(defaultMetaData());
newUser.setUserType(UserType.LDAP);
newUser.setRole(UserRole.USER);
newUser.setExpired(false);
user.setEmail(email);
user.setMetadata(defaultMetaData());
user.setUserType(UserType.LDAP);
user.setRole(UserRole.USER);
user.setExpired(false);

final Project project = generatePersonalProject(newUser);
newUser.getProjects().add(project.getUsers().iterator().next());
final Project project = generatePersonalProject(user);
user.getProjects().add(project.getUsers().iterator().next());

return userRepository.save(newUser);
return userRepository.save(user);
}

private String getFullName(DirContextOperations ctx, Map<String, String> syncAttributes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public User replicateUser(ReportPortalSamlAuthentication samlAuthentication) {

User user = new User();
user.setLogin(userName);
user.setUuid(UUID.randomUUID());
user.setActive(Boolean.TRUE);

List<Attribute> details = samlAuthentication.getDetails();

Expand Down

0 comments on commit 3219456

Please sign in to comment.