allow user.add with given userid, if it is free
This commit is contained in:
parent
c109b20bc4
commit
75a68d707a
@ -95,9 +95,6 @@ public class UnixUserModuleImpl extends AbstractModuleImpl {
|
|||||||
}
|
}
|
||||||
if (passWord.indexOf(':') >= 0) {
|
if (passWord.indexOf(':') >= 0) {
|
||||||
throw new AuthorisationException(loginUser, "add", newUnixUser, "userId");
|
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");
|
Query qPac = em.createQuery("SELECT obj FROM Pacs obj WHERE obj.name = :pacName");
|
||||||
qPac.setParameter("pacName", userName.substring(0, 5));
|
qPac.setParameter("pacName", userName.substring(0, 5));
|
||||||
@ -117,11 +114,14 @@ public class UnixUserModuleImpl extends AbstractModuleImpl {
|
|||||||
newUnixUser.setUserId(nUID);
|
newUnixUser.setUserId(nUID);
|
||||||
} else {
|
} else {
|
||||||
// given uid belongs to same pac?
|
// 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("userId", newUnixUser.getUserId());
|
||||||
q.setParameter("pac", pac);
|
q.setParameter("pac", pac);
|
||||||
List<?> idOfSamePac = q.getResultList();
|
List<?> idOfSamePac = q.getResultList();
|
||||||
if (idOfSamePac.size() == 0) {
|
if (idOfSamePac.isEmpty() && !idExists.isEmpty()) {
|
||||||
throw new AuthorisationException(loginUser, "add", newUnixUser, "userId");
|
throw new AuthorisationException(loginUser, "add", newUnixUser, "userId");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user