aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/FacebookLogin.java5
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/VKontakteLogin.java5
-rw-r--r--juick-www/src/main/webapp/WEB-INF/layouts/content.html2
3 files changed, 9 insertions, 3 deletions
diff --git a/juick-www/src/main/java/com/juick/www/controllers/FacebookLogin.java b/juick-www/src/main/java/com/juick/www/controllers/FacebookLogin.java
index 2b2a89b2..6e8d6864 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/FacebookLogin.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/FacebookLogin.java
@@ -130,7 +130,10 @@ public class FacebookLogin {
if (!crosspostService.updateFacebookUser(fbID, token.getAccessToken(), fb.getName(), fb.getLink())) {
throw new HttpBadRequestException();
}
- return "redirect:/?hash=" + userService.getHashByUID(uid);
+ Cookie c = new Cookie("hash", userService.getHashByUID(uid));
+ c.setMaxAge(50 * 24 * 60 * 60);
+ response.addCookie(c);
+ return Utils.getPreviousPageByRequest(request).orElse("redirect:/");
} else if (fb.getVerified()) {
String loginhash = UUID.randomUUID().toString();
if (!crosspostService.createFacebookUser(fbID, loginhash, token.getAccessToken(), fb.getName(), fb.getLink())) {
diff --git a/juick-www/src/main/java/com/juick/www/controllers/VKontakteLogin.java b/juick-www/src/main/java/com/juick/www/controllers/VKontakteLogin.java
index 23cbedff..382c3194 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/VKontakteLogin.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/VKontakteLogin.java
@@ -123,7 +123,10 @@ public class VKontakteLogin {
Long vkID = NumberUtils.toLong(jsonUser.getUid(), 0);
int uid = crosspostService.getUIDbyVKID(vkID);
if (uid > 0) {
- return "redirect:/?hash=" + userService.getHashByUID(uid);
+ Cookie c = new Cookie("hash", userService.getHashByUID(uid));
+ c.setMaxAge(50 * 24 * 60 * 60);
+ response.addCookie(c);
+ return Utils.getPreviousPageByRequest(request).orElse("redirect:/");
} else {
String loginhash = UUID.randomUUID().toString();
if (!crosspostService.createVKUser(vkID, loginhash, token.getAccessToken(), vkName, vkLink)) {
diff --git a/juick-www/src/main/webapp/WEB-INF/layouts/content.html b/juick-www/src/main/webapp/WEB-INF/layouts/content.html
index 78d79eb0..f4ca0d84 100644
--- a/juick-www/src/main/webapp/WEB-INF/layouts/content.html
+++ b/juick-www/src/main/webapp/WEB-INF/layouts/content.html
@@ -43,7 +43,7 @@
}
</script>
</head>
-<body id="body" data-hash="{{ visitor.authHash | default('') }}">
+<body id="body" {% if visitor.uid > 0 %}data-hash="{{visitor.authHash}}"{% endif %}>
{% include "views/partial/navigation" %}
<div id="wrapper">
{% if visitor.uid == 0 %}