Commit ba400709 authored by Matija Obreza's avatar Matija Obreza

Fix: deepLoad(user) must be called in getUserByEmail

- User missing ROLE_EVERYONE
parent 3ba95e70
......@@ -120,7 +120,7 @@ public class UserServiceImpl extends BasicUserServiceImpl<UserRole, User> implem
user.setAccountType(accountType);
user.getRoles().add(UserRole.USER);
super.setPassword(user, password);
return userRepository.save(user);
return deepLoad(userRepository.save(user));
}
@Transactional
......@@ -279,23 +279,13 @@ public class UserServiceImpl extends BasicUserServiceImpl<UserRole, User> implem
@Override
public User getUserByEmail(String email) {
final User user = userRepository.findByEmail(email);
if (user != null) {
user.getRoles().size();
}
return user;
return deepLoad(user);
}
@Override
public User getUserByUuid(String uuid) {
final User user = userRepository.findByUuid(uuid);
if (user != null) {
user.getRoles().size();
}
return user;
return deepLoad(user);
}
@Override
......
......@@ -67,6 +67,7 @@ public class UserServiceTest extends AbstractServicesTest {
user = userService.createUser(email, fullName, initialPassword, AccountType.LOCAL);
assertEquals(user.getAccountType(), AccountType.LOCAL);
assertThat(user.getRoles(), containsInAnyOrder(UserRole.USER, UserRole.EVERYONE));
assertThat(passwordEncoder.matches(initialPassword, user.getPassword()), is(true));
}
......@@ -230,7 +231,7 @@ public class UserServiceTest extends AbstractServicesTest {
@Test
public void updateRolesTest() throws PasswordPolicyException {
assertThat(userService.getUserByEmail(email).getRoles(), hasSize(1));
assertThat(userService.getUserByEmail(email).getRoles(), hasSize(2));
Set<UserRole> selectedRoles = Sets.newHashSet(UserRole.ADMINISTRATOR);
userService.setRoles(user, selectedRoles);
assertThat(userService.getUserByEmail(email).getRoles(), hasSize(3));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment