コード例 #1
0
 private boolean exists(User user) {
   if (user == null || user.getId() == null) {
     return false;
   }
   if (!userRepository.exists(user.getId())) {
     return false;
   }
   return true;
 }
コード例 #2
0
 private User saveUser(User user) {
   if (!exists(user)) {
     user.setCreated(new Date());
   }
   if (isUserNameAlreadyTaken(user.getName())) {
     throw new UserNameIsTakenException("Name " + user.getName() + " has already been taken.");
   }
   User u = userRepository.save(user);
   return u;
 }
コード例 #3
0
 @Transactional
 @Override
 public User saveUserWithNewPassword(User user, Set<String> authorityNames, String rawPassword) {
   List<Authority> authorities = retrieveAuthoritiesByNames(authorityNames);
   // Surely whatever was in user authorities is discarded at this point
   user.setAuthorities(authorities);
   return saveUserWithNewPassword(user, rawPassword);
 }
コード例 #4
0
 @Transactional
 @Override
 public User saveUserWithNewPassword(User user, String rawPassword) {
   validate(user, rawPassword);
   user.setPassword(passwordEncoder.encode(rawPassword));
   user = saveUser(user);
   return user;
 }