diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/java/Login.properties | 2 | ||||
-rw-r--r-- | src/java/Login_ru.properties | 2 | ||||
-rw-r--r-- | src/java/com/juick/http/www/Login.java | 18 | ||||
-rw-r--r-- | src/java/com/juick/http/www/VKontakteLogin.java | 7 |
4 files changed, 26 insertions, 3 deletions
diff --git a/src/java/Login.properties b/src/java/Login.properties index f75010af1..f8b3919b3 100644 --- a/src/java/Login.properties +++ b/src/java/Login.properties @@ -5,6 +5,8 @@ Login=Login Username=Username Password=Password Login\ Facebook=Login with Facebook +Login\ VK=Login with VKontakte +Login\ VK\ text=Login Login\ XMPP=Login with Jabber/XMPP XMPP\ instructions=Send <strong>LOGIN</strong> from your Jabber/XMPP account to <strong>juick@juick.com</strong>. Have\ Juick=Have a Juick account? diff --git a/src/java/Login_ru.properties b/src/java/Login_ru.properties index 84eef0164..6d5922e42 100644 --- a/src/java/Login_ru.properties +++ b/src/java/Login_ru.properties @@ -5,6 +5,8 @@ Login=\u0412\u0445\u043e\u0434 Username=\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f Password=\u041f\u0430\u0440\u043e\u043b\u044c Login\ Facebook=\u0412\u043e\u0439\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 Facebook +Login\ VK=\u0412\u043e\u0439\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 \u0412\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u0435 +Login\ VK\ text=\u0412\u043e\u0439\u0442\u0438 Login\ XMPP=\u0412\u043e\u0439\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 Jabber/XMPP XMPP\ instructions=\u041e\u0442\u043f\u0440\u0430\u0432\u044c\u0442\u0435 <strong>LOGIN</strong> \u0441 \u0432\u0430\u0448\u0435\u0433\u043e \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430 Jabber/XMPP \u043d\u0430 <strong>juick@juick.com</strong>. Have\ Juick=\u0423\u0436\u0435 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043d\u0430 Juick? 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; } |