示例#1
0
 @Override
 @Transactional
 public User removeOne(Long id) {
   User user = findOne(id);
   user.setEnabled(false);
   return save(user);
 }
示例#2
0
 @Transactional
 public User save(User user, boolean changePassword) {
   if (changePassword) {
     user.setPassword(passwordEncoder.encode(user.getPassword()));
   } else if (!user.isNew()) {
     user.setPassword(findOne(user.getId()).getPassword());
   }
   return userRepository.saveAndFlush(user);
 }
示例#3
0
  @Override
  @Transactional(readOnly = true)
  public List<User> findAll() {
    List<User> resultList = new ArrayList<User>();
    if (DilectuUtils.isAdministrator()) {
      resultList = userRepository.findAll();
    } else {
      List<User> userList = findByTenant(TenantContextHolder.getTenant());

      for (User user : userList) {
        if (!user.getGroup().getPermissions().contains(UserPermission.ADMIN)) {
          resultList.add(user);
        }
      }
    }

    return resultList;
  }