diff --git a/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java b/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java index 111c123..b677e54 100644 --- a/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java @@ -95,9 +95,6 @@ public class UnixUserModuleImpl extends AbstractModuleImpl { } if (passWord.indexOf(':') >= 0) { throw new AuthorisationException(loginUser, "add", newUnixUser, "userId"); - } - if (newUnixUser.getPac() == null || newUnixUser.getPac().getNew()) { - } Query qPac = em.createQuery("SELECT obj FROM Pacs obj WHERE obj.name = :pacName"); qPac.setParameter("pacName", userName.substring(0, 5)); @@ -117,11 +114,14 @@ public class UnixUserModuleImpl extends AbstractModuleImpl { newUnixUser.setUserId(nUID); } else { // given uid belongs to same pac? - Query q = em.createQuery("SELECT u.userId FROM UnixUsers u WHERE u.userId = :userId AND u.pac = :pac"); + Query q = em.createQuery("SELECT u.userId FROM UnixUsers u WHERE u.userId = :userId"); + q.setParameter("userId", newUnixUser.getUserId()); + List idExists = q.getResultList(); + q = em.createQuery("SELECT u.userId FROM UnixUsers u WHERE u.userId = :userId AND u.pac = :pac"); q.setParameter("userId", newUnixUser.getUserId()); q.setParameter("pac", pac); List idOfSamePac = q.getResultList(); - if (idOfSamePac.size() == 0) { + if (idOfSamePac.isEmpty() && !idExists.isEmpty()) { throw new AuthorisationException(loginUser, "add", newUnixUser, "userId"); } }