diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/juick/server/UserQueries.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main/java/com/juick/server/UserQueries.java b/src/main/java/com/juick/server/UserQueries.java index 184d26f5..2ae47da4 100644 --- a/src/main/java/com/juick/server/UserQueries.java +++ b/src/main/java/com/juick/server/UserQueries.java @@ -63,6 +63,16 @@ public class UserQueries { } return hash; } + public static String getSignUpHashByTelegramID(JdbcTemplate sql, Long telegramId) { + try { + return sql.queryForObject("SELECT loginhash FROM telegram WHERE tg_id=? AND user_id IS NULL", + String.class, telegramId); + } catch (EmptyResultDataAccessException e) { + String hash = UUID.randomUUID().toString(); + sql.update("INSERT INTO telegram(tg_id, loginhash) VALUES (?, ?)", telegramId, hash); + return hash; + } + } public static int createUser(JdbcTemplate sql, String username, String password) { KeyHolder holder = new GeneratedKeyHolder(); |