From 3890570bf190a63f8f34c47a7fd21e780a61b6b0 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 17 Jan 2017 11:57:50 +0300 Subject: juick-www: Facebook and VK login using scribejava --- juick-www/src/main/java/com/juick/www/Utils.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'juick-www/src/main/java/com/juick/www/Utils.java') diff --git a/juick-www/src/main/java/com/juick/www/Utils.java b/juick-www/src/main/java/com/juick/www/Utils.java index 37016ed2..d7b5597d 100644 --- a/juick-www/src/main/java/com/juick/www/Utils.java +++ b/juick-www/src/main/java/com/juick/www/Utils.java @@ -32,6 +32,7 @@ import java.net.URL; import java.net.URLConnection; import java.nio.charset.StandardCharsets; import java.util.Arrays; +import java.util.Optional; /** * @@ -108,4 +109,15 @@ public class Utils { return null; } } + /** + * Returns the viewName to return for coming back to the sender url + * + * @param request Instance of {@link HttpServletRequest} or use an injected instance + * @return Optional with the view name. Recomended to use an alternativa url with + * {@link Optional#orElse(java.lang.Object)} + */ + public static Optional getPreviousPageByRequest(HttpServletRequest request) + { + return Optional.ofNullable(request.getHeader("Referer")).map(requestUrl -> "redirect:" + requestUrl); + } } -- cgit v1.2.3