diff options
Diffstat (limited to 'src/com/juick')
-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; |