diff options
author | Vitaly Takmazov | 2023-01-11 06:57:36 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-11 06:57:36 +0300 |
commit | 6c3663df82c7e29febc0aebd51717184df7da09c (patch) | |
tree | 6b987923e6b28081352f67687306a5c410a2c738 /src/main/java/com/juick/service/UserServiceImpl.java | |
parent | e96411433898f940b22257affba284787e2783cd (diff) |
Social login refactoring: set cookie after login
Diffstat (limited to 'src/main/java/com/juick/service/UserServiceImpl.java')
-rw-r--r-- | src/main/java/com/juick/service/UserServiceImpl.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/com/juick/service/UserServiceImpl.java b/src/main/java/com/juick/service/UserServiceImpl.java index ab947bac..69ca7569 100644 --- a/src/main/java/com/juick/service/UserServiceImpl.java +++ b/src/main/java/com/juick/service/UserServiceImpl.java @@ -783,6 +783,22 @@ public class UserServiceImpl extends BaseJdbcService implements UserService { return list.isEmpty() ? StringUtils.EMPTY : list.get(0); } + @Override + @Transactional(readOnly = true) + public Optional<User> getUserByTelegramId(Long id) { + List<User> list = getJdbcTemplate().query( + """ + SELECT DISTINCT u.id, u.nick, u.passw, u.banned, u.last_seen, + COALESCE(f.fb_id, vk.vk_id, t.tg_id, e.user_id, 0) AS verified + FROM users u LEFT JOIN facebook f ON f.user_id = u.id + LEFT JOIN vk ON u.id = vk.user_id LEFT JOIN telegram t ON u.id = t.user_id + LEFT JOIN emails e ON e.user_id = u.id + WHERE t.tg_id = ?""", + new UserMapper(), id + ); + + return list.isEmpty() ? Optional.empty() : Optional.of(list.get(0)); + } @Transactional(readOnly = true) @Override |