Beispiel #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);
 }
Beispiel #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;
 }
Beispiel #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;
  }
Beispiel #4
0
 @Override
 @Transactional(readOnly = true)
 public List<User> findAll(Specification<User> specification) {
   return userRepository.findAll(specification);
 }
Beispiel #5
0
 @Transactional(readOnly = true)
 @Override
 public User findSystemUser() {
   return userRepository.findByUsername(SYSTEM_LOGIN);
 }
Beispiel #6
0
 @Transactional(readOnly = true)
 @Override
 public User findOne(Long id) {
   return userRepository.findOne(id);
 }
Beispiel #7
0
 @Transactional(readOnly = true)
 @Override
 public User findByUsername(String username) {
   return userRepository.findByUsername(username);
 }
Beispiel #8
0
 @Override
 @Transactional(readOnly = true)
 public List<User> findByTenant(String tenant) {
   return userRepository.findByTenant(tenant);
 }
Beispiel #9
0
 @Override
 @Transactional(readOnly = true)
 public List<User> findUserUniqueUsername(User instance) {
   return userRepository.findAll(UserSpecification.isUniqueUsername(instance));
 }