From ea43e78cb8dc20c2f54a15e37dba638b963f65ec Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 13 May 2016 16:12:44 +0300 Subject: telegram login --- src/main/java/com/juick/server/UserQueries.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/main/java') 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(); -- cgit v1.2.3