aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www/Utils.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-01-17 11:57:50 +0300
committerGravatar Vitaly Takmazov2017-01-17 14:14:30 +0300
commit3890570bf190a63f8f34c47a7fd21e780a61b6b0 (patch)
tree94ee4a300ae032c3e01ba8bfc17ea462f0511578 /juick-www/src/main/java/com/juick/www/Utils.java
parent965d46f8188378eea8acb99e8f6c448a26a1ee19 (diff)
juick-www: Facebook and VK login using scribejava
Diffstat (limited to 'juick-www/src/main/java/com/juick/www/Utils.java')
-rw-r--r--juick-www/src/main/java/com/juick/www/Utils.java12
1 files changed, 12 insertions, 0 deletions
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<String> getPreviousPageByRequest(HttpServletRequest request)
+ {
+ return Optional.ofNullable(request.getHeader("Referer")).map(requestUrl -> "redirect:" + requestUrl);
+ }
}