mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-23 10:45:23 +01:00
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:
parent
724de1e121
commit
dccbd5262f
@ -229,15 +229,6 @@ public class CacheDataSource implements DataSource {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateIp(String user, String ip) {
|
||||
boolean result = source.updateIp(user, ip);
|
||||
if (result) {
|
||||
cachedAuths.refresh(user);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
return source.getAllAuths();
|
||||
|
@ -186,15 +186,6 @@ public interface DataSource extends Reloadable {
|
||||
*/
|
||||
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.
|
||||
*
|
||||
|
@ -486,11 +486,6 @@ public class FlatFile implements DataSource {
|
||||
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
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
BufferedReader br = null;
|
||||
|
@ -790,20 +790,6 @@ public class MySQL implements DataSource {
|
||||
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
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
List<PlayerAuth> auths = new ArrayList<>();
|
||||
|
@ -555,20 +555,6 @@ public class SQLite implements DataSource {
|
||||
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
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
List<PlayerAuth> auths = new ArrayList<>();
|
||||
|
@ -139,11 +139,6 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
captchaManager.increaseCount(name);
|
||||
tempbanManager.increaseCount(ip);
|
||||
|
||||
if (!pAuth.getIp().equals(ip)) {
|
||||
pAuth.setIp(ip);
|
||||
database.updateIp(pAuth.getNickname(), ip);
|
||||
}
|
||||
|
||||
String email = pAuth.getEmail();
|
||||
boolean passwordVerified = forceLogin || passwordSecurity.comparePassword(
|
||||
password, pAuth.getPassword(), player.getName());
|
||||
|
@ -271,22 +271,6 @@ public abstract class AbstractDataSourceIntegrationTest {
|
||||
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
|
||||
public void shouldCountAuths() {
|
||||
// given
|
||||
|
Loading…
Reference in New Issue
Block a user