aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/juick/http/www/SignUp.java
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2013-03-31 09:47:16 +0700
committerGravatar Ugnich Anton2013-03-31 09:47:16 +0700
commit04492e5cd1996c71b05cade8a4205276ea205770 (patch)
treea55472b0c0f78ca92cab5cf23df86802bcbd4248 /src/java/com/juick/http/www/SignUp.java
parentcdd48f30c7fca97327de48ff6b1cd9edf1629a5d (diff)
Vkontakte signup
Diffstat (limited to 'src/java/com/juick/http/www/SignUp.java')
-rw-r--r--src/java/com/juick/http/www/SignUp.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/java/com/juick/http/www/SignUp.java b/src/java/com/juick/http/www/SignUp.java
index 1afbebbe..46049451 100644
--- a/src/java/com/juick/http/www/SignUp.java
+++ b/src/java/com/juick/http/www/SignUp.java
@@ -52,6 +52,8 @@ public class SignUp {
String account = null;
if (type.equals("fb")) {
account = getFacebookNameByHash(sql, hash);
+ } else if (type.equals("vk")) {
+ account = getVKNameByHash(sql, hash);
} else if (type.equals("xmpp")) {
account = getJIDByHash(sql, hash);
}
@@ -72,6 +74,8 @@ public class SignUp {
out.print("<h1 class=\"signup-h1\">");
if (type.charAt(0) == 'f') {
out.print("<img src=\"//static.juick.com/settings/facebook.png\" alt=\"Facebook\"/>");
+ } else if (type.charAt(0) == 'v') {
+ out.print("<img src=\"//static.juick.com/settings/vk.png\" alt=\"VKontakte\"/>");
} else if (type.charAt(0) == 'x') {
out.print("<img src=\"//static.juick.com/settings/xmpp.png\" alt=\"XMPP\"/>");
}
@@ -153,6 +157,7 @@ public class SignUp {
}
if (!(type.charAt(0) == 'f' && setFacebookUser(sql, hash, uid))
+ && !(type.charAt(0) == 'v' && setVKUser(sql, hash, uid))
&& !(type.charAt(0) == 'x' && setJIDUser(sql, hash, uid))) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
@@ -174,6 +179,7 @@ public class SignUp {
}
if (!(type.charAt(0) == 'f' && setFacebookUser(sql, hash, uid))
+ && !(type.charAt(0) == 'v' && setVKUser(sql, hash, uid))
&& !(type.charAt(0) == 'x' && setJIDUser(sql, hash, uid))) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
@@ -230,6 +236,44 @@ public class SignUp {
return ret;
}
+ private String getVKNameByHash(Connection sql, String hash) {
+ String ret = null;
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT vk_name,vk_link FROM vk WHERE loginhash=?");
+ stmt.setString(1, hash);
+ rs = stmt.executeQuery();
+ if (rs.first()) {
+ ret = "<a href=\"http://vk.com/" + rs.getString(2) + "\" rel=\"nofollow\">" + rs.getString(1) + "</a>";
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+
+ return ret;
+ }
+
+ private boolean setVKUser(Connection sql, String hash, int uid) {
+ boolean ret = false;
+ PreparedStatement stmt = null;
+ try {
+ stmt = sql.prepareStatement("UPDATE vk SET user_id=?,loginhash=NULL WHERE loginhash=?");
+ stmt.setInt(1, uid);
+ stmt.setString(2, hash);
+ stmt.executeUpdate();
+ ret = true;
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(null, stmt);
+ }
+ return ret;
+ }
+
private String getJIDByHash(Connection sql, String hash) {
String ret = null;