From 0fc01edf83f47ba9e19b9ea44ab2232cab4fe4a1 Mon Sep 17 00:00:00 2001 From: Petr Ilin Date: Mon, 23 Jan 2023 01:31:47 +0300 Subject: Removing players from the session/premium cache when changing passwords --- build.gradle | 2 +- src/main/java/net/elytrium/limboauth/LimboAuth.java | 4 ++-- .../java/net/elytrium/limboauth/command/ChangePasswordCommand.java | 6 +++++- .../net/elytrium/limboauth/command/ForceChangePasswordCommand.java | 5 ++++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 987ac36..d159a01 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ plugins { } setGroup("net.elytrium") -setVersion("1.1.5") +setVersion("1.1.6-SNAPSHOT") java { setSourceCompatibility(JavaVersion.VERSION_11) diff --git a/src/main/java/net/elytrium/limboauth/LimboAuth.java b/src/main/java/net/elytrium/limboauth/LimboAuth.java index 6851d4f..1dcd22b 100644 --- a/src/main/java/net/elytrium/limboauth/LimboAuth.java +++ b/src/main/java/net/elytrium/limboauth/LimboAuth.java @@ -333,8 +333,8 @@ public class LimboAuth { manager.register("unregister", new UnregisterCommand(this, this.playerDao), "unreg"); manager.register("premium", new PremiumCommand(this, this.playerDao), "license"); manager.register("forceunregister", new ForceUnregisterCommand(this, this.server, this.playerDao), "forceunreg"); - manager.register("changepassword", new ChangePasswordCommand(this.playerDao), "changepass", "cp"); - manager.register("forcechangepassword", new ForceChangePasswordCommand(this.server, this.playerDao), "forcechangepass", "fcp"); + manager.register("changepassword", new ChangePasswordCommand(this, this.playerDao), "changepass", "cp"); + manager.register("forcechangepassword", new ForceChangePasswordCommand(this, this.server, this.playerDao), "forcechangepass", "fcp"); manager.register("destroysession", new DestroySessionCommand(this), "logout"); if (Settings.IMP.MAIN.ENABLE_TOTP) { manager.register("2fa", new TotpCommand(this.playerDao), "totp"); diff --git a/src/main/java/net/elytrium/limboauth/command/ChangePasswordCommand.java b/src/main/java/net/elytrium/limboauth/command/ChangePasswordCommand.java index 2fea6f5..ebe9032 100644 --- a/src/main/java/net/elytrium/limboauth/command/ChangePasswordCommand.java +++ b/src/main/java/net/elytrium/limboauth/command/ChangePasswordCommand.java @@ -34,6 +34,7 @@ import net.kyori.adventure.text.Component; public class ChangePasswordCommand implements SimpleCommand { + private final LimboAuth plugin; private final Dao playerDao; private final boolean needOldPass; @@ -44,7 +45,8 @@ public class ChangePasswordCommand implements SimpleCommand { private final Component usage; private final Component notPlayer; - public ChangePasswordCommand(Dao playerDao) { + public ChangePasswordCommand(LimboAuth plugin, Dao playerDao) { + this.plugin = plugin; this.playerDao = playerDao; Serializer serializer = LimboAuth.getSerializer(); @@ -94,6 +96,8 @@ public class ChangePasswordCommand implements SimpleCommand { updateBuilder.updateColumnValue(RegisteredPlayer.HASH_FIELD, RegisteredPlayer.genHash(needOldPass ? args[1] : args[0])); updateBuilder.update(); + this.plugin.removePlayerFromCache(username); + source.sendMessage(this.successful); } catch (SQLException e) { source.sendMessage(this.errorOccurred); diff --git a/src/main/java/net/elytrium/limboauth/command/ForceChangePasswordCommand.java b/src/main/java/net/elytrium/limboauth/command/ForceChangePasswordCommand.java index 67d9c67..9e769e8 100644 --- a/src/main/java/net/elytrium/limboauth/command/ForceChangePasswordCommand.java +++ b/src/main/java/net/elytrium/limboauth/command/ForceChangePasswordCommand.java @@ -36,6 +36,7 @@ import net.kyori.adventure.text.Component; public class ForceChangePasswordCommand implements SimpleCommand { + private final LimboAuth plugin; private final ProxyServer server; private final Dao playerDao; @@ -44,7 +45,8 @@ public class ForceChangePasswordCommand implements SimpleCommand { private final String notSuccessful; private final Component usage; - public ForceChangePasswordCommand(ProxyServer server, Dao playerDao) { + public ForceChangePasswordCommand(LimboAuth plugin, ProxyServer server, Dao playerDao) { + this.plugin = plugin; this.server = server; this.playerDao = playerDao; @@ -75,6 +77,7 @@ public class ForceChangePasswordCommand implements SimpleCommand { updateBuilder.updateColumnValue(RegisteredPlayer.HASH_FIELD, RegisteredPlayer.genHash(newPassword)); updateBuilder.update(); + this.plugin.removePlayerFromCache(nickname); this.server.getPlayer(nickname) .ifPresent(player -> player.sendMessage(serializer.deserialize(MessageFormat.format(this.message, newPassword)))); -- cgit