Password has been changed.
"; String hash = userService.getHashByUID(visitor.getUid()); Cookie c = new Cookie("hash", hash); c.setMaxAge(365 * 24 * 60 * 60); response.addCookie(c); } break; case "about": visitor.setFullName(request.getParameter("fullname")); visitor.setCountry(request.getParameter("country")); visitor.setUrl(request.getParameter("url")); visitor.setDescription(request.getParameter("descr")); try { String avatarTmpPath = HttpUtils .receiveMultiPartFile(newAvatar, storageService.getTemporaryDirectory()).getHost(); if (StringUtils.isNotEmpty(avatarTmpPath)) { storageService.saveAvatar(avatarTmpPath, visitor); } if (userService.updateUserInfo(visitor)) { result = String.format("Your info is updated.
", visitor.getName()); } applicationEventPublisher.publishEvent(new UpdateUserEvent(this, visitor)); } catch (Exception e) { result = "" + e.getMessage() + ". Back.
"; } break; case "jid-del": // FIXME: stop using ugnich-csv in parameters String[] params = request.getParameter("delete").split(";", 2); boolean res = false; if (params[0].equals("xmpp")) { res = userService.deleteJID(visitor.getUid(), params[1]); } else if (params[0].equals("xmpp-unauth")) { res = userService.unauthJID(visitor.getUid(), params[1]); } if (res) { result = "Deleted. Back.
"; } else { result = "Error
"; } break; case "email-add": if (!emailService.isValidEmail(request.getParameter("account"))) { result = "Invalid email. Back.
"; } else { if (!emailService.verifyAddressByCode(visitor.getUid(), request.getParameter("account"))) { String authCode = RandomStringUtils.randomAlphanumeric(8).toUpperCase(); if (emailService.addVerificationCode(visitor.getUid(), request.getParameter("account"), authCode)) { Session session = Session.getDefaultInstance(System.getProperties()); try { MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress("noreply@juick.com")); message.addRecipient(Message.RecipientType.TO, new InternetAddress(request.getParameter("account"))); message.setSubject("Juick authorization link"); message.setText(String.format("Follow link to attach this email to Juick account:\n" + "https://juick.com/settings?page=auth-email&code=%s\n\n" + "If you don't know, what this mean - just ignore this mail.\n", authCode)); Transport.send(message); result = "Authorization link has been sent to your email. Follow it to proceed.
" + ""; } catch (MessagingException ex) { logger.error("mail exception", ex); throw new HttpBadRequestException(); } } } } break; case "email-del": if (emailService.deleteEmail(visitor.getUid(), request.getParameter("account"))) { result = "Deleted. Back.
"; } else { result = "An error occured while deleting.
"; } break; case "email-subscr": if (emailService.setNotificationsEmail(visitor.getUid(), request.getParameter("account"))) { result = String.format("Saved! Will send notifications to %s." + "
", request.getParameter("account")); } else { result = "Disabled.
"; } break; case "twitter-del": userService.deleteTwitterToken(visitor.getUid()); for (Cookie cookie : request.getCookies()) { if (cookie.getName().equals("request_token")) { cookie.setMaxAge(0); response.addCookie(cookie); } if (cookie.getName().equals("request_token_secret")) { cookie.setMaxAge(0); response.addCookie(cookie); } } result = ""; break; case "telegram-del": if (userService.canDeleteTelegramUser(visitor)) { telegramService.deleteTelegramUser(visitor.getUid()); } result = ""; break; case "facebook-disable": userService.disableFBCrosspost(visitor.getUid()); result = ""; break; case "facebook-enable": userService.enableFBCrosspost(visitor.getUid()); result = ""; break; case "vk-del": userService.deleteVKUser(visitor.getUid()); result = ""; break; default: throw new HttpBadRequestException(); } model.addAttribute("title", "Настройки"); model.addAttribute("visitor", visitor); model.addAttribute("result", result); return "views/settings_result"; } @PostMapping("/settings/unsubscribe") public String unsubscribeOneClick( User user, @RequestParam(name = "List-Unsubscribe") String unsubscribe, ModelMap model) { if (!user.isAnonymous()) { if (unsubscribe.equals("One-Click")) { emailService.setNotificationsEmail(user.getUid(), StringUtils.EMPTY); model.addAttribute("title", "Настройки"); model.addAttribute("visitor", user); model.addAttribute("result", "Unsubscribed"); return "views/settings_result"; } } throw new HttpBadRequestException(); } }