diff --git a/src/main/java/info/bukova/isspst/services/users/UserServiceImpl.java b/src/main/java/info/bukova/isspst/services/users/UserServiceImpl.java index 4c891cab..9a3df4cc 100644 --- a/src/main/java/info/bukova/isspst/services/users/UserServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/users/UserServiceImpl.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Set; import org.hibernate.Query; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.encoding.PasswordEncoder; import org.springframework.security.core.Authentication; @@ -21,6 +22,8 @@ import info.bukova.isspst.services.AbstractService; public class UserServiceImpl extends AbstractService implements UserService { private PasswordEncoder encoder; + @Autowired + private RoleService roleService; public void setEncoder(PasswordEncoder encoder) { this.encoder = encoder; @@ -114,5 +117,16 @@ public class UserServiceImpl extends AbstractService implements UserServic return q.list(); } + @Override + protected User createEntity() { + User u = new User(); + Role r = roleService.getRoleByAuthority(Constants.ROLE_USER); + if (r != null) { + u.addAuthority(r); + } + u.setEnabled(true); + return u; + } + }