From 07cf790e0f77f7ce77fabd9f6d3f87879987b14c Mon Sep 17 00:00:00 2001 From: Petr Ilin Date: Sun, 25 Dec 2022 20:15:59 +0300 Subject: Fix ChangePasswordCommand for premium users --- .../limboauth/command/ChangePasswordCommand.java | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/elytrium/limboauth/command/ChangePasswordCommand.java b/src/main/java/net/elytrium/limboauth/command/ChangePasswordCommand.java index 5506c40..6c00e18 100644 --- a/src/main/java/net/elytrium/limboauth/command/ChangePasswordCommand.java +++ b/src/main/java/net/elytrium/limboauth/command/ChangePasswordCommand.java @@ -71,17 +71,16 @@ public class ChangePasswordCommand implements SimpleCommand { } boolean onlineMode = player.getHash().isEmpty(); - if (this.needOldPass) { - if (!onlineMode) { - if (args.length < 2) { - source.sendMessage(this.usage); - return; - } + boolean needOldPass = this.needOldPass && !onlineMode; + if (needOldPass) { + if (args.length < 2) { + source.sendMessage(this.usage); + return; + } - if (!AuthSessionHandler.checkPassword(args[0], player, this.playerDao)) { - source.sendMessage(this.wrongPassword); - return; - } + if (!AuthSessionHandler.checkPassword(args[0], player, this.playerDao)) { + source.sendMessage(this.wrongPassword); + return; } } else if (args.length < 1) { source.sendMessage(this.usage); @@ -91,7 +90,7 @@ public class ChangePasswordCommand implements SimpleCommand { try { UpdateBuilder updateBuilder = this.playerDao.updateBuilder(); updateBuilder.where().eq(RegisteredPlayer.NICKNAME_FIELD, username); - updateBuilder.updateColumnValue(RegisteredPlayer.HASH_FIELD, AuthSessionHandler.genHash(this.needOldPass ? args[1] : args[0])); + updateBuilder.updateColumnValue(RegisteredPlayer.HASH_FIELD, AuthSessionHandler.genHash(needOldPass ? args[1] : args[0])); updateBuilder.update(); source.sendMessage(this.successful); -- cgit