public String validateRegistration(String key) {
log.debug("Validating registration for key {}", key);
String login = registrationRepository.getLoginByRegistrationKey(key);
String password = RandomUtil.generatePassword();
StandardPasswordEncoder encoder = new StandardPasswordEncoder();
String encryptedPassword = encoder.encode(password);
if (login != null) {
User existingUser = getUserByLogin(login);
if (existingUser != null) {
log.debug("Reinitializing password for user {}", login);
existingUser.setPassword(encryptedPassword);