aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Ilin <hevav@hevav.dev>2022-12-25 20:15:59 +0300
committerPetr Ilin <hevav@hevav.dev>2022-12-25 20:15:59 +0300
commit07cf790e0f77f7ce77fabd9f6d3f87879987b14c (patch)
treed2935a936a041009ec0ecac8d66df7ed0edc7579
parent97212dac465d38dbc7f4104e8a6fe0a76ada8744 (diff)
downloadLimboAuth-07cf790e0f77f7ce77fabd9f6d3f87879987b14c.tar.gz
LimboAuth-07cf790e0f77f7ce77fabd9f6d3f87879987b14c.tar.bz2
LimboAuth-07cf790e0f77f7ce77fabd9f6d3f87879987b14c.zip
Fix ChangePasswordCommand for premium users
-rw-r--r--src/main/java/net/elytrium/limboauth/command/ChangePasswordCommand.java21
1 files 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<RegisteredPlayer, String> 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);