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 "main": NotifyOpts opts = new NotifyOpts(); opts.setRepliesEnabled(StringUtils.isNotEmpty(request.getParameter("jnotify"))); opts.setSubscriptionsEnabled(StringUtils.isNotEmpty(request.getParameter("subscr_notify"))); opts.setRecommendationsEnabled(StringUtils.isNotEmpty(request.getParameter("recomm"))); if (subscriptionService.setNotifyOptions(visitor, opts)) { result = "Notification options has been updated
"; } break; case "about": UserInfo info = new UserInfo(); info.setFullName(request.getParameter("fullname")); info.setCountry(request.getParameter("country")); info.setUrl(request.getParameter("url")); info.setDescription(request.getParameter("descr")); String avatarTmpPath = HttpUtils.receiveMultiPartFile(avatar, webApp.getTmpDir()); if (StringUtils.isNotEmpty(avatarTmpPath)) { String originalExtension = FilenameUtils.getExtension(avatarTmpPath); String originalName = String.format("%s.%s", visitor.getUid(), originalExtension); String targetName = String.format("%s.png", visitor.getUid()); Path ao = Paths.get(webApp.getImgDir(), "ao", originalName); Path a = Paths.get(webApp.getImgDir(), "a", targetName); Path as = Paths.get(webApp.getImgDir(), "as", targetName); Files.move(Paths.get(webApp.getTmpDir(), avatarTmpPath), ao, StandardCopyOption.REPLACE_EXISTING); Thumbnails.of(ao.toFile()).size(96, 96).toFile(a.toFile()); Thumbnails.of(ao.toFile()).size(32, 32).toFile(as.toFile()); } if (userService.updateUserInfo(visitor, info)) { result = String.format("Your info is updated.
", visitor.getName()); } 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": String newHash = userService.updateSecretEmail(visitor); if (StringUtils.isNotEmpty(newHash)) { result = String.format("New secret email: %s@mail.juick.com
" + "Back.
", newHash); } else { throw new HttpBadRequestException(); } break; case "email-add": try { emailService.verifyAddressByCode(visitor.getUid(), request.getParameter("account")); } catch (EmptyResultDataAccessException e) { String authCode = UserUtils.generateHash(8); 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@mail.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" + "http://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.setSubscriptionHour(visitor.getUid(), request.getParameter("account"), request.getParameter("time"))) { result = String.format("Saved! Will send to %s at %s:00 GMT." + "
", request.getParameter("account"), request.getParameter("time")); } else { result = "Disabled.
"; } break; case "twitter-del": crosspostService.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": telegramService.deleteTelegramUser(visitor.getUid()); result = ""; break; case "facebook-disable": crosspostService.disableFBCrosspost(visitor.getUid()); result = ""; break; case "facebook-enable": crosspostService.enableFBCrosspost(visitor.getUid()); result = ""; break; case "vk-del": crosspostService.deleteVKUser(visitor.getUid()); result = ""; break; default: throw new HttpBadRequestException(); } model.addAttribute("title", "Настройки"); model.addAttribute("visitor", visitor); model.addAttribute("result", result); model.addAttribute("readonly", messagesService.isReadonly()); return "views/settings_result"; } }