From 7e73ada4e2e568818f9221068c8687728f2c9ce8 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 7 Sep 2018 15:56:34 +0300 Subject: Fix referer redirect --- juick-server/src/main/java/com/juick/server/www/Utils.java | 2 +- .../src/main/java/com/juick/server/www/controllers/SocialLogin.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'juick-server/src/main/java/com/juick/server') diff --git a/juick-server/src/main/java/com/juick/server/www/Utils.java b/juick-server/src/main/java/com/juick/server/www/Utils.java index 61278e17..e53c142b 100644 --- a/juick-server/src/main/java/com/juick/server/www/Utils.java +++ b/juick-server/src/main/java/com/juick/server/www/Utils.java @@ -40,6 +40,6 @@ public class Utils { */ public static Optional getPreviousPageByRequest(HttpServletRequest request) { - return Optional.ofNullable(request.getHeader("Referer")).map(requestUrl -> "redirect:" + requestUrl); + return Optional.ofNullable(request.getHeader("Referer")); } } diff --git a/juick-server/src/main/java/com/juick/server/www/controllers/SocialLogin.java b/juick-server/src/main/java/com/juick/server/www/controllers/SocialLogin.java index 5f21e052..46e25d81 100644 --- a/juick-server/src/main/java/com/juick/server/www/controllers/SocialLogin.java +++ b/juick-server/src/main/java/com/juick/server/www/controllers/SocialLogin.java @@ -280,7 +280,7 @@ public class SocialLogin { Cookie c = new Cookie("hash", userService.getHashByUID(uid)); c.setMaxAge(50 * 24 * 60 * 60); response.addCookie(c); - return Utils.getPreviousPageByRequest(request).orElse("redirect:/"); + return "redirect:/" + Utils.getPreviousPageByRequest(request).orElse(StringUtils.EMPTY); } else { String loginhash = UUID.randomUUID().toString(); if (!crosspostService.createVKUser(vkID, loginhash, token.getAccessToken(), vkName, vkLink)) { @@ -310,7 +310,7 @@ public class SocialLogin { Cookie c = new Cookie("hash", userService.getHashByUID(uid)); c.setMaxAge(50 * 24 * 60 * 60); response.addCookie(c); - return Utils.getPreviousPageByRequest(request).orElse("redirect:/"); + return "redirect:/" + Utils.getPreviousPageByRequest(request).orElse(StringUtils.EMPTY); } else { String username = StringUtils.defaultString(params.get("username"), params.get("first_name")); telegramService.createTelegramUser(tgUser, username); -- cgit v1.2.3