use of org.openforis.collect.model.User in project collect by openforis.
the class PasswordChangeValidator method validateOldPassword.
private void validateOldPassword(Errors errors) {
if (validateRequiredField(errors, OLD_PASSWORD_FIELD)) {
String oldPassword = (String) errors.getFieldValue(OLD_PASSWORD_FIELD);
User loggedUser = sessionManager.getLoggedUser();
if (!userManager.verifyPassword(loggedUser.getUsername(), oldPassword)) {
errors.rejectValue(OLD_PASSWORD_FIELD, WRONG_PASSWORD_SPECIFIED_MESSAGE_KEY);
}
}
}
use of org.openforis.collect.model.User in project collect by openforis.
the class RecordLockManager method checkIsLocked.
public synchronized boolean checkIsLocked(int recordId, User user, String sessionId) throws RecordUnlockedException {
RecordLock lock = getLock(recordId);
String lockUserName = null;
if (lock != null) {
String lockSessionId = lock.getSessionId();
int lockRecordId = lock.getRecordId();
User lUser = lock.getUser();
if (recordId == lockRecordId && (lUser == user || lUser.getId().equals(user.getId())) && lockSessionId.equals(sessionId)) {
lock.keepAlive();
return true;
} else {
User lockUser = lock.getUser();
lockUserName = lockUser.getUsername();
}
}
throw new RecordUnlockedException(lockUserName);
}
use of org.openforis.collect.model.User in project collect by openforis.
the class RecordLockManager method isForceUnlockAllowed.
private boolean isForceUnlockAllowed(User user, RecordLock lock) {
boolean isAdmin = user.hasRole(UserRole.ADMIN);
Integer userId = user.getId();
User lockUser = lock.getUser();
return isAdmin || userId.equals(lockUser.getId());
}
use of org.openforis.collect.model.User in project collect by openforis.
the class LocalUserManager method isDefaultAdminPasswordSet.
public Boolean isDefaultAdminPasswordSet() {
User adminUser = loadAdminUser();
String encodedDefaultPassword = encodePassword(ADMIN_DEFAULT_PASSWORD);
return encodedDefaultPassword.equals(adminUser.getPassword());
}
use of org.openforis.collect.model.User in project collect by openforis.
the class LocalUserManager method deleteById.
@Override
@Transactional(readOnly = false, propagation = REQUIRED)
public void deleteById(Integer id) throws CannotDeleteUserException {
if (recordDao.hasAssociatedRecords(id)) {
throw new CannotDeleteUserException();
}
User user = userDao.loadById(id);
groupManager.deleteAllUserRelations(user);
userDao.delete(id);
User cachedUser = userById.get(id);
if (cachedUser != null) {
userById.remove(id);
userByName.remove(cachedUser.getUsername());
}
}
Aggregations