public void changePassword(String password) { userRepository .findOneByLogin(SecurityUtils.getCurrentUserLogin()) .ifPresent( u -> { String encryptedPassword = passwordEncoder.encode(password); u.setPassword(encryptedPassword); userRepository.save(u); log.debug("Changed password for User: {}", u); }); }
public void updateUserInformation( String firstName, String lastName, String email, String langKey) { userRepository .findOneByLogin(SecurityUtils.getCurrentUserLogin()) .ifPresent( u -> { u.setFirstName(firstName); u.setLastName(lastName); u.setEmail(email); u.setLangKey(langKey); userRepository.save(u); userSearchRepository.save(u); log.debug("Changed Information for User: {}", u); }); }
@Transactional(readOnly = true) public User getUserWithAuthorities() { User user = userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()).get(); user.getAuthorities().size(); // eagerly load the association return user; }