diff options
Diffstat (limited to 'src/main/java/com/juick/www/controllers')
-rw-r--r-- | src/main/java/com/juick/www/controllers/SocialLogin.java | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/main/java/com/juick/www/controllers/SocialLogin.java b/src/main/java/com/juick/www/controllers/SocialLogin.java index dad3d969..c9611543 100644 --- a/src/main/java/com/juick/www/controllers/SocialLogin.java +++ b/src/main/java/com/juick/www/controllers/SocialLogin.java @@ -154,23 +154,23 @@ public class SocialLogin { throw new HttpBadRequestException(); } User fb = jsonMapper.readValue(graph, User.class); - long fbID = NumberUtils.toLong(fb.getId(), 0); - if (fbID == 0 || StringUtils.isBlank(fb.getName())) { - logger.error("Missing required fields, id: {}, name: {}", fbID, fb.getName()); + long fbID = NumberUtils.toLong(fb.id(), 0); + if (fbID == 0 || StringUtils.isBlank(fb.name())) { + logger.error("Missing required fields, id: {}, name: {}", fbID, fb.name()); throw new HttpBadRequestException(); } Optional<com.juick.model.User> existingFacebookUser = userService.getUserByFacebookId(fbID); if (existingFacebookUser.isPresent()) { - if (!userService.updateFacebookUser(fbID, token.getAccessToken(), fb.getName())) { + if (!userService.updateFacebookUser(fbID, token.getAccessToken(), fb.name())) { logger.error("error updating facebook user, id: {}, token: {}", fbID, token.getAccessToken()); throw new HttpBadRequestException(); } - if (StringUtils.isNotEmpty(fb.getEmail())) { - logger.info("found {} for facebook user {}", fb.getEmail(), fb.getName()); + if (StringUtils.isNotEmpty(fb.email())) { + logger.info("found {} for facebook user {}", fb.email(), fb.name()); Optional<com.juick.model.User> newFacebookUser = userService.getUserByFacebookId(fbID); - if (!emailService.getEmails(newFacebookUser.get().getUid(), false).contains(fb.getEmail())) { - emailService.addEmail(newFacebookUser.get().getUid(), fb.getEmail()); + if (!emailService.getEmails(newFacebookUser.get().getUid(), false).contains(fb.email())) { + emailService.addEmail(newFacebookUser.get().getUid(), fb.email()); } } if (!existingFacebookUser.get().isBanned()) { @@ -183,7 +183,7 @@ public class SocialLogin { return "redirect:/login"; } } else { - if (!userService.createFacebookUser(fbID, state, token.getAccessToken(), fb.getName())) { + if (!userService.createFacebookUser(fbID, state, token.getAccessToken(), fb.name())) { throw new HttpBadRequestException(); } return "redirect:/signup?type=fb&hash=" + state; @@ -226,7 +226,7 @@ public class SocialLogin { com.juick.model.ext.twitter.User twitterUser = jsonMapper.readValue( oAuthService.execute(oAuthRequest).getBody(), com.juick.model.ext.twitter.User.class); if (userService.linkTwitterAccount(user, accessToken.getToken(), accessToken.getTokenSecret(), - twitterUser.getScreenName())) { + twitterUser.screenName())) { response.setStatus(HttpServletResponse.SC_FOUND); response.setHeader("Location", "http://juick.com/settings"); } else { @@ -264,17 +264,17 @@ public class SocialLogin { Response vkResponse = vkAuthService.execute(meRequest); if (vkResponse.isSuccessful()) { String graph = vkResponse.getBody(); - com.juick.model.ext.vk.User jsonUser = jsonMapper.readValue(graph, UsersResponse.class).getUsers().stream() + com.juick.model.ext.vk.User jsonUser = jsonMapper.readValue(graph, UsersResponse.class).users().stream() .findFirst().orElseThrow(HttpBadRequestException::new); - String vkName = jsonUser.getFirstName() + " " + jsonUser.getLastName(); - String vkLink = jsonUser.getScreenName(); + String vkName = jsonUser.firstName() + " " + jsonUser.lastName(); + String vkLink = jsonUser.screenName(); if (vkName.length() == 1 || StringUtils.isBlank(vkLink)) { logger.error("vk user error"); throw new HttpBadRequestException(); } - long vkID = NumberUtils.toLong(jsonUser.getId(), 0); + long vkID = NumberUtils.toLong(jsonUser.id(), 0); int uid = userService.getUIDbyVKID(vkID); if (uid > 0) { Cookie c = new Cookie("hash", userService.getHashByUID(uid)); |