diff options
author | Ugnich Anton | 2013-11-26 15:57:46 +0700 |
---|---|---|
committer | Ugnich Anton | 2013-11-26 15:57:46 +0700 |
commit | 5ec828b377b18d6cf56643796de8fdd44e8f1091 (patch) | |
tree | e4937aa3a4ce1834fd350424fe91d5c86b3dba30 /src/com/juick/server/UserQueries.java | |
parent | 4844ef8ea55d8b88619af8400df1bbf690842f7f (diff) |
getSignUpHashByJID
Diffstat (limited to 'src/com/juick/server/UserQueries.java')
-rw-r--r-- | src/com/juick/server/UserQueries.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/com/juick/server/UserQueries.java b/src/com/juick/server/UserQueries.java index b1198e4d..716f8f0f 100644 --- a/src/com/juick/server/UserQueries.java +++ b/src/com/juick/server/UserQueries.java @@ -24,6 +24,7 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.Random; +import java.util.UUID; /** * @@ -33,6 +34,27 @@ public class UserQueries { static final String ABCDEF = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + public static String getSignUpHashByJID(Connection sql, String jid) { + String hash = SQLHelpers.getString(sql, "SELECT loginhash FROM jids WHERE jid=? AND user_id IS NULL", jid); + + if (hash == null) { + hash = UUID.randomUUID().toString(); + PreparedStatement stmt = null; + try { + stmt = sql.prepareStatement("INSERT INTO jids(jid,loginhash) VALUES (?,?)"); + stmt.setString(1, jid); + stmt.setString(2, hash); + stmt.executeUpdate(); + } catch (SQLException e) { + System.err.println(e); + } finally { + Utils.finishSQL(null, stmt); + } + } + + return hash; + } + public static int createUser(Connection sql, String username, String password, String lang) { int uid = 0; |