コード例 #1
0
 public void changePassword(String password) {
   userRepository
       .findOneByLogin(SecurityUtils.getCurrentUser().getUsername())
       .ifPresent(
           u -> {
             String encryptedPassword = passwordEncoder.encode(password);
             u.setPassword(encryptedPassword);
             userRepository.save(u);
             log.debug("Changed password for User: {}", u);
           });
 }
コード例 #2
0
 public void updateUserInformation(
     String firstName, String lastName, String email, String langKey) {
   userRepository
       .findOneByLogin(SecurityUtils.getCurrentUser().getUsername())
       .ifPresent(
           u -> {
             u.setFirstName(firstName);
             u.setLastName(lastName);
             u.setEmail(email);
             u.setLangKey(langKey);
             userRepository.save(u);
             log.debug("Changed Information for User: {}", u);
           });
 }
コード例 #3
0
 @Transactional(readOnly = true)
 public User getUserWithRoles() {
   User user = userRepository.findOneByLogin(SecurityUtils.getCurrentUser().getUsername()).get();
   user.getRoles().size(); // eagerly load the association
   return user;
 }