diff options
author | Petr Ilin <hevav@hevav.dev> | 2022-04-03 17:14:31 +0300 |
---|---|---|
committer | Petr Ilin <hevav@hevav.dev> | 2022-04-03 17:14:31 +0300 |
commit | b86b1ec801bca9eaf75be8eafe043062cbf9c7a0 (patch) | |
tree | 518ba7865565e24c551b7a2e8831bef6161afa4c /src/main/java/net | |
parent | c25bc379e38c803bbbf96c3318723da4cec7e6be (diff) | |
download | LimboAuth-b86b1ec801bca9eaf75be8eafe043062cbf9c7a0.tar.gz LimboAuth-b86b1ec801bca9eaf75be8eafe043062cbf9c7a0.tar.bz2 LimboAuth-b86b1ec801bca9eaf75be8eafe043062cbf9c7a0.zip |
Session fix
Diffstat (limited to 'src/main/java/net')
-rw-r--r-- | src/main/java/net/elytrium/limboauth/LimboAuth.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/main/java/net/elytrium/limboauth/LimboAuth.java b/src/main/java/net/elytrium/limboauth/LimboAuth.java index ebf56b9..bdde110 100644 --- a/src/main/java/net/elytrium/limboauth/LimboAuth.java +++ b/src/main/java/net/elytrium/limboauth/LimboAuth.java @@ -361,9 +361,10 @@ public class LimboAuth { } public void cacheAuthUser(Player player) { - String username = player.getUsername().toLowerCase(Locale.ROOT); - this.cachedAuthChecks.remove(username); - this.cachedAuthChecks.put(username, new CachedSessionUser(player.getRemoteAddress().getAddress(), System.currentTimeMillis())); + String username = player.getUsername(); + String lowercaseUsername = username.toLowerCase(Locale.ROOT); + this.cachedAuthChecks.remove(lowercaseUsername); + this.cachedAuthChecks.put(lowercaseUsername, new CachedSessionUser(player.getRemoteAddress().getAddress(), username, System.currentTimeMillis())); } public void removePlayerFromCache(String username) { @@ -375,7 +376,8 @@ public class LimboAuth { if (!this.cachedAuthChecks.containsKey(username)) { return true; } else { - return !this.cachedAuthChecks.get(username).getInetAddress().equals(player.getRemoteAddress().getAddress()); + CachedSessionUser sessionUser = this.cachedAuthChecks.get(username); + return !sessionUser.getInetAddress().equals(player.getRemoteAddress().getAddress()) || !sessionUser.getUsername().equals(username); } } @@ -587,15 +589,21 @@ public class LimboAuth { private static class CachedSessionUser extends CachedUser { private final InetAddress inetAddress; + private final String username; - public CachedSessionUser(InetAddress inetAddress, long checkTime) { + public CachedSessionUser(InetAddress inetAddress, String username, long checkTime) { super(checkTime); this.inetAddress = inetAddress; + this.username = username; } public InetAddress getInetAddress() { return this.inetAddress; } + + public String getUsername() { + return this.username; + } } private static class CachedPremiumUser extends CachedUser { |