diff options
Diffstat (limited to 'src/java/com/juick')
-rw-r--r-- | src/java/com/juick/http/www/Login.java | 18 | ||||
-rw-r--r-- | src/java/com/juick/http/www/VKontakteLogin.java | 7 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/java/com/juick/http/www/Login.java b/src/java/com/juick/http/www/Login.java index 3a715870b..7ad921e02 100644 --- a/src/java/com/juick/http/www/Login.java +++ b/src/java/com/juick/http/www/Login.java @@ -37,6 +37,11 @@ public class Login { protected void doGetLoginForm(Connection sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { com.juick.User visitor = Utils.getVisitorUser(sql, request); + if (visitor != null) { + Utils.sendTemporaryRedirect(response, "/"); + return; + } + Locale locale = request.getLocale(); ResourceBundle rb = ResourceBundle.getBundle("Login", locale); @@ -52,6 +57,9 @@ public class Login { out.println("<h1 class=\"signup-h1\"><img src=\"//static.juick.com/settings/facebook.png\" alt=\"Facebook\"/>" + rb.getString("Login Facebook") + "</h1>"); out.println("<p><a href=\"/_fblogin\" rel=\"nofollow\"><img src=\"//static.juick.com/facebook-connect.png\" alt=\"Connect with Facebook\"/></a></p>"); out.println("<hr class=\"signup-hr\"/>"); + out.println("<h1 class=\"signup-h1\"><img src=\"//static.juick.com/settings/vk.png\" alt=\"VK\"/>" + rb.getString("Login VK") + "</h1>"); + out.println("<p><a href=\"/_vklogin\" rel=\"nofollow\">" + rb.getString("Login VK text") + "</a></p>"); + out.println("<hr class=\"signup-hr\"/>"); out.println("<h1 class=\"signup-h1\"><img src=\"//static.juick.com/settings/xmpp.png\" alt=\"XMPP\"/>" + rb.getString("Login XMPP") + "</h1>"); out.println("<p>" + rb.getString("XMPP instructions") + "</p>"); out.println("<hr class=\"signup-hr\"/>"); @@ -84,6 +92,11 @@ public class Login { c.setMaxAge(365 * 24 * 60 * 60); response.addCookie(c); + Cookie c2 = new Cookie("hash", "-"); + c2.setDomain(".juick.com"); + c2.setMaxAge(0); + response.addCookie(c2); + response.sendRedirect("/"); } else { response.sendError(403); @@ -105,6 +118,11 @@ public class Login { c.setMaxAge(365 * 24 * 60 * 60); response.addCookie(c); + Cookie c2 = new Cookie("hash", "-"); + c2.setDomain(".juick.com"); + c2.setMaxAge(0); + response.addCookie(c2); + String referer = request.getHeader("Referer"); if (referer != null && referer.startsWith("http://juick.com/") && !referer.equals("http://juick.com/login")) { response.sendRedirect(referer); diff --git a/src/java/com/juick/http/www/VKontakteLogin.java b/src/java/com/juick/http/www/VKontakteLogin.java index e7252b57c..5f26fef14 100644 --- a/src/java/com/juick/http/www/VKontakteLogin.java +++ b/src/java/com/juick/http/www/VKontakteLogin.java @@ -38,8 +38,8 @@ import org.json.JSONObject; */ public class VKontakteLogin { - private static final String VK_APPID = "3531222"; - private static final String VK_SECRET = "EhgW6VJrl02oFPO0buiJ"; + private static final String VK_APPID = "3544101"; + private static final String VK_SECRET = "z2afNI8jA5lIpZ2jsTm1"; private static final String VK_REDIRECT = "http://juick.com/_vklogin"; protected void doGet(Connection sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { @@ -84,7 +84,7 @@ public class VKontakteLogin { } try { - JSONObject json = new JSONObject(graph); + JSONObject json = new JSONObject(graph).getJSONArray("response").getJSONObject(0); String vkName = json.getString("first_name") + " " + json.getString("last_name"); String vkLink = json.getString("screen_name"); @@ -108,6 +108,7 @@ public class VKontakteLogin { response.setHeader("Location", "/signup?type=vk&hash=" + loginhash); } } catch (Exception e) { + System.err.println("JSON ERROR: " + e); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } |