diff options
author | 2016-05-13 16:12:44 +0300 | |
---|---|---|
committer | 2016-05-13 16:12:44 +0300 | |
commit | ea43e78cb8dc20c2f54a15e37dba638b963f65ec (patch) | |
tree | 5f6e9cee04e09c1adbe3a6e1f83ae2081cf84c8a /src/main/java | |
parent | c95b63af82ed58c68876563692340d74ced156f2 (diff) |
telegram login
Diffstat (limited to 'src/main/java')
-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(); |