Example #1
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);
 }
Example #2
0
 @Transactional(readOnly = true)
 @Override
 public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
   User user = userRepository.findByUsername(username);
   if (user == null) {
     throw new UsernameNotFoundException("The username could not be found on database.");
   }
   return user;
 }
Example #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;
  }
Example #4
0
 @Override
 @Transactional(readOnly = true)
 public List<User> findAll(Specification<User> specification) {
   return userRepository.findAll(specification);
 }
Example #5
0
 @Transactional(readOnly = true)
 @Override
 public User findSystemUser() {
   return userRepository.findByUsername(SYSTEM_LOGIN);
 }
Example #6
0
 @Transactional(readOnly = true)
 @Override
 public User findOne(Long id) {
   return userRepository.findOne(id);
 }
Example #7
0
 @Transactional(readOnly = true)
 @Override
 public User findByUsername(String username) {
   return userRepository.findByUsername(username);
 }
Example #8
0
 @Override
 @Transactional(readOnly = true)
 public List<User> findByTenant(String tenant) {
   return userRepository.findByTenant(tenant);
 }
Example #9
0
 @Override
 @Transactional(readOnly = true)
 public List<User> findUserUniqueUsername(User instance) {
   return userRepository.findAll(UserSpecification.isUniqueUsername(instance));
 }