From 87da42e3385e368f05d88ff125a78605a18f9cc3 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 28 Jun 2016 10:36:04 +0300 Subject: fix getuserbyhash --- src/main/java/com/juick/server/UserQueries.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/main/java/com/juick') diff --git a/src/main/java/com/juick/server/UserQueries.java b/src/main/java/com/juick/server/UserQueries.java index 3a0e03ba..ca562765 100644 --- a/src/main/java/com/juick/server/UserQueries.java +++ b/src/main/java/com/juick/server/UserQueries.java @@ -187,11 +187,15 @@ public class UserQueries { } public static com.juick.User getUserByHash(JdbcTemplate sql, String hash) { - User user = sql.queryForObject("SELECT logins.user_id,users.nick, users.banned FROM logins " + - "INNER JOIN users ON logins.user_id=users.id WHERE logins.hash=?", - new UserMapper(), hash); - user.setAuthHash(hash); - return user; + try { + User user = sql.queryForObject("SELECT logins.user_id,users.nick, users.banned FROM logins " + + "INNER JOIN users ON logins.user_id=users.id WHERE logins.hash=?", + new UserMapper(), hash); + user.setAuthHash(hash); + return user; + } catch (EmptyResultDataAccessException e) { + return new User(); + } } public static String getHashByUID(JdbcTemplate sql, int uid) { -- cgit v1.2.3