diff options
author | Vitaly Takmazov | 2018-05-04 01:24:47 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-05-04 01:24:47 +0300 |
commit | 729017fa0267521cfa85279cbb36f23bd423adb0 (patch) | |
tree | 9fb3ad4250b38a52d3c63f966622c303ca6c9743 /juick-server-jdbc/src/main/java/com/juick/service/CrosspostServiceImpl.java | |
parent | bc2a475df38b0fbe04c6f563d80bf529cd941ca6 (diff) |
www: facebook login refactoring
Diffstat (limited to 'juick-server-jdbc/src/main/java/com/juick/service/CrosspostServiceImpl.java')
-rw-r--r-- | juick-server-jdbc/src/main/java/com/juick/service/CrosspostServiceImpl.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/juick-server-jdbc/src/main/java/com/juick/service/CrosspostServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/CrosspostServiceImpl.java index 9f9d699f..0bd5fe66 100644 --- a/juick-server-jdbc/src/main/java/com/juick/service/CrosspostServiceImpl.java +++ b/juick-server-jdbc/src/main/java/com/juick/service/CrosspostServiceImpl.java @@ -54,6 +54,21 @@ public class CrosspostServiceImpl extends BaseJdbcService implements CrosspostSe && getJdbcTemplate().update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=1741", uid) > 0; } + @Override + public void addFacebookState(String state) { + jdbcTemplate.update("INSERT INTO facebook(loginhash) VALUES(?)", state); + } + + @Override + public boolean verifyFacebookState(String state) { + try { + return jdbcTemplate.queryForObject("SELECT COUNT(loginhash) FROM facebook WHERE loginhash=?", + Integer.class, state) == 1; + } catch (EmptyResultDataAccessException e) { + return false; + } + } + @Transactional(readOnly = true) @Override public Optional<Pair<String, String>> getFacebookTokens(final int uid) { @@ -157,8 +172,8 @@ public class CrosspostServiceImpl extends BaseJdbcService implements CrosspostSe @Transactional @Override public boolean createFacebookUser(long fbID, String loginhash, String token, String fbName, String fbLink) { - return getJdbcTemplate().update("INSERT INTO facebook(fb_id,loginhash,access_token,fb_name,fb_link) VALUES (?,?,?,?,?)", - fbID, loginhash, token, fbName, fbLink) > 0; + return getJdbcTemplate().update("UPDATE facebook SET fb_id=?, access_token=?, fb_name=?, fb_link=? WHERE loginhash=?", + fbID, token, fbName, fbLink, loginhash) > 0; } @Transactional |