Don't update IP twice

- IP is updated in datasource#updateSession after successful login
- Remove no longer used DataSource#updateIp
This commit is contained in:
ljacqu 2016-07-12 21:43:07 +02:00
parent 724de1e121
commit dccbd5262f
7 changed files with 0 additions and 72 deletions

View File

@ -229,15 +229,6 @@ public class CacheDataSource implements DataSource {
return result; return result;
} }
@Override
public boolean updateIp(String user, String ip) {
boolean result = source.updateIp(user, ip);
if (result) {
cachedAuths.refresh(user);
}
return result;
}
@Override @Override
public List<PlayerAuth> getAllAuths() { public List<PlayerAuth> getAllAuths() {
return source.getAllAuths(); return source.getAllAuths();

View File

@ -186,15 +186,6 @@ public interface DataSource extends Reloadable {
*/ */
boolean updateRealName(String user, String realName); boolean updateRealName(String user, String realName);
/**
* Update a player's IP address.
*
* @param user The name of the user (lowercase)
* @param ip The IP address to save
* @return True upon success, false upon failure
*/
boolean updateIp(String user, String ip);
/** /**
* Return all players of the database. * Return all players of the database.
* *

View File

@ -486,11 +486,6 @@ public class FlatFile implements DataSource {
throw new UnsupportedOperationException("Flat file no longer supported"); throw new UnsupportedOperationException("Flat file no longer supported");
} }
@Override
public boolean updateIp(String user, String ip) {
throw new UnsupportedOperationException("Flat file no longer supported");
}
@Override @Override
public List<PlayerAuth> getAllAuths() { public List<PlayerAuth> getAllAuths() {
BufferedReader br = null; BufferedReader br = null;

View File

@ -790,20 +790,6 @@ public class MySQL implements DataSource {
return false; return false;
} }
@Override
public boolean updateIp(String user, String ip) {
String sql = "UPDATE " + tableName + " SET " + col.IP + "=? WHERE " + col.NAME + "=?;";
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
pst.setString(1, ip);
pst.setString(2, user);
pst.executeUpdate();
return true;
} catch (SQLException ex) {
logSqlException(ex);
}
return false;
}
@Override @Override
public List<PlayerAuth> getAllAuths() { public List<PlayerAuth> getAllAuths() {
List<PlayerAuth> auths = new ArrayList<>(); List<PlayerAuth> auths = new ArrayList<>();

View File

@ -555,20 +555,6 @@ public class SQLite implements DataSource {
return false; return false;
} }
@Override
public boolean updateIp(String user, String ip) {
String sql = "UPDATE " + tableName + " SET " + col.IP + "=? WHERE " + col.NAME + "=?;";
try (PreparedStatement pst = con.prepareStatement(sql)) {
pst.setString(1, ip);
pst.setString(2, user);
pst.executeUpdate();
return true;
} catch (SQLException ex) {
logSqlException(ex);
}
return false;
}
@Override @Override
public List<PlayerAuth> getAllAuths() { public List<PlayerAuth> getAllAuths() {
List<PlayerAuth> auths = new ArrayList<>(); List<PlayerAuth> auths = new ArrayList<>();

View File

@ -139,11 +139,6 @@ public class AsynchronousLogin implements AsynchronousProcess {
captchaManager.increaseCount(name); captchaManager.increaseCount(name);
tempbanManager.increaseCount(ip); tempbanManager.increaseCount(ip);
if (!pAuth.getIp().equals(ip)) {
pAuth.setIp(ip);
database.updateIp(pAuth.getNickname(), ip);
}
String email = pAuth.getEmail(); String email = pAuth.getEmail();
boolean passwordVerified = forceLogin || passwordSecurity.comparePassword( boolean passwordVerified = forceLogin || passwordSecurity.comparePassword(
password, pAuth.getPassword(), player.getName()); password, pAuth.getPassword(), player.getName());

View File

@ -271,22 +271,6 @@ public abstract class AbstractDataSourceIntegrationTest {
assertThat(dataSource.getAllAuths(), hasItem(hasAuthBasicData("user", "user", email, "34.56.78.90"))); assertThat(dataSource.getAllAuths(), hasItem(hasAuthBasicData("user", "user", email, "34.56.78.90")));
} }
@Test
public void shouldUpdateIp() {
// given
DataSource dataSource = getDataSource();
String ip = "250.230.67.73";
// when
boolean response1 = dataSource.updateIp("bobby", ip);
boolean response2 = dataSource.updateIp("bogus", "123.123.123.123");
// then
assertThat(response1 && response2, equalTo(true));
assertThat(dataSource.getAllAuths(), hasItem(hasAuthBasicData("bobby", "Bobby", "your@email.com", ip)));
}
@Test @Test
public void shouldCountAuths() { public void shouldCountAuths() {
// given // given