From 8a0fbbd35c13054a947ea0d27ca117542bc452b9 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 18 May 2018 15:33:38 +0300 Subject: JPA WIP --- .../java/com/juick/www/controllers/Settings.java | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'juick-www/src/main/java/com/juick/www/controllers/Settings.java') diff --git a/juick-www/src/main/java/com/juick/www/controllers/Settings.java b/juick-www/src/main/java/com/juick/www/controllers/Settings.java index f9527423..702f52af 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/Settings.java +++ b/juick-www/src/main/java/com/juick/www/controllers/Settings.java @@ -96,20 +96,20 @@ public class Settings { model.addAttribute("visitor", visitor); model.addAttribute("tags", tagService.getPopularTags()); model.addAttribute("auths", userService.getAuthCodes(visitor)); - model.addAttribute("email_active", emailService.getNotificationsEmail(visitor.getUid())); + model.addAttribute("email_active", emailService.getNotificationsEmail(visitor)); model.addAttribute("ehash", userService.getEmailHash(visitor)); model.addAttribute("emails", userService.getEmails(visitor)); model.addAttribute("jids", userService.getAllJIDs(visitor)); List hours = IntStream.rangeClosed(0, 23).boxed() .map(i -> StringUtils.leftPad(String.format("%d", i), 2, "0")).collect(Collectors.toList()); model.addAttribute("hours", hours); - model.addAttribute("fbstatus", crosspostService.getFbCrossPostStatus(visitor.getUid())); - model.addAttribute("twitter_name", crosspostService.getTwitterName(visitor.getUid())); - model.addAttribute("telegram_name", crosspostService.getTelegramName(visitor.getUid())); + model.addAttribute("fbstatus", crosspostService.getFbCrossPostStatus(visitor)); + model.addAttribute("twitter_name", crosspostService.getTwitterName(visitor)); + model.addAttribute("telegram_name", crosspostService.getTelegramName(visitor)); model.addAttribute("notify_options", subscriptionService.getNotifyOptions(visitor)); model.addAttribute("userinfo", userService.getUserInfo(visitor)); if (page.equals("auth-email")) { - if (emailService.verifyAddressByCode(visitor.getUid(), request.getParameter("code"))) { + if (emailService.verifyAddressByCode(visitor, request.getParameter("code"))) { ; model.addAttribute("result", "OK!"); } else { @@ -140,7 +140,7 @@ public class Settings { case "password": if (userService.updatePassword(visitor, request.getParameter("password"))) { result = "

Password has been changed.

"; - String hash = userService.getHashByUID(visitor.getUid()); + String hash = userService.getHashForUser(visitor); Cookie c = new Cookie("hash", hash); c.setMaxAge(365 * 24 * 60 * 60); response.addCookie(c); @@ -186,9 +186,9 @@ public class Settings { } break; case "email-add": - if (!emailService.verifyAddressByCode(visitor.getUid(), request.getParameter("account"))) { + if (!emailService.verifyAddressByCode(visitor, request.getParameter("account"))) { String authCode = RandomStringUtils.randomAlphanumeric(8).toUpperCase(); - if (emailService.addVerificationCode(visitor.getUid(), request.getParameter("account"), authCode)) { + if (emailService.addVerificationCode(visitor, request.getParameter("account"), authCode)) { Session session = Session.getDefaultInstance(System.getProperties()); try { MimeMessage message = new MimeMessage(session); @@ -210,14 +210,14 @@ public class Settings { } break; case "email-del": - if (emailService.deleteEmail(visitor.getUid(), request.getParameter("account"))) { + if (emailService.deleteEmail(visitor, 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"))) { + if (emailService.setNotificationsEmail(visitor, request.getParameter("account"))) { result = String.format("

Saved! Will send notifications to %s." + "

Back

", request.getParameter("account")); } else { @@ -225,7 +225,7 @@ public class Settings { } break; case "twitter-del": - crosspostService.deleteTwitterToken(visitor.getUid()); + crosspostService.deleteTwitterToken(visitor); for (Cookie cookie : request.getCookies()) { if (cookie.getName().equals("request_token")) { cookie.setMaxAge(0); @@ -246,15 +246,15 @@ public class Settings { result = "

Back

"; break; case "facebook-disable": - crosspostService.disableFBCrosspost(visitor.getUid()); + crosspostService.disableFBCrosspost(visitor); result = "

Back

"; break; case "facebook-enable": - crosspostService.enableFBCrosspost(visitor.getUid()); + crosspostService.enableFBCrosspost(visitor); result = "

Back

"; break; case "vk-del": - crosspostService.deleteVKUser(visitor.getUid()); + crosspostService.deleteVKUser(visitor); result = "

Back

"; break; default: -- cgit v1.2.3