From 601e3eedcbc0a820c6aace1ed22329273a9e553b Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Mon, 7 Jul 2014 14:05:47 +0200 Subject: [PATCH] =?UTF-8?q?Nov=C3=BD=20u=C5=BEivatel=20se=20automaticky=20?= =?UTF-8?q?ozna=C4=8D=C3=AD=20jako=20aktivn=C3=AD=20a=20p=C5=99i=C5=99ad?= =?UTF-8?q?=C3=AD=20se=20mu=20role=20user.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../isspst/services/users/UserServiceImpl.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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; + } + }