aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/net/elytrium/limboauth/event/PostAuthorizationEvent.java4
-rw-r--r--src/main/java/net/elytrium/limboauth/event/PostEvent.java11
-rw-r--r--src/main/java/net/elytrium/limboauth/event/PostRegisterEvent.java4
-rw-r--r--src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java20
4 files changed, 28 insertions, 11 deletions
diff --git a/src/main/java/net/elytrium/limboauth/event/PostAuthorizationEvent.java b/src/main/java/net/elytrium/limboauth/event/PostAuthorizationEvent.java
index 0fed613..8449fa1 100644
--- a/src/main/java/net/elytrium/limboauth/event/PostAuthorizationEvent.java
+++ b/src/main/java/net/elytrium/limboauth/event/PostAuthorizationEvent.java
@@ -23,7 +23,7 @@ import net.elytrium.limboauth.model.RegisteredPlayer;
public class PostAuthorizationEvent extends PostEvent {
- public PostAuthorizationEvent(Consumer<TaskEvent> onComplete, LimboPlayer player, RegisteredPlayer playerInfo) {
- super(onComplete, player, playerInfo);
+ public PostAuthorizationEvent(Consumer<TaskEvent> onComplete, LimboPlayer player, RegisteredPlayer playerInfo, String password) {
+ super(onComplete, player, playerInfo, password);
}
}
diff --git a/src/main/java/net/elytrium/limboauth/event/PostEvent.java b/src/main/java/net/elytrium/limboauth/event/PostEvent.java
index e3f590a..1a37fea 100644
--- a/src/main/java/net/elytrium/limboauth/event/PostEvent.java
+++ b/src/main/java/net/elytrium/limboauth/event/PostEvent.java
@@ -25,19 +25,22 @@ public abstract class PostEvent extends TaskEvent {
private final LimboPlayer player;
private final RegisteredPlayer playerInfo;
+ private final String password;
- protected PostEvent(Consumer<TaskEvent> onComplete, LimboPlayer player, RegisteredPlayer playerInfo) {
+ protected PostEvent(Consumer<TaskEvent> onComplete, LimboPlayer player, RegisteredPlayer playerInfo, String password) {
super(onComplete);
this.player = player;
this.playerInfo = playerInfo;
+ this.password = password;
}
- protected PostEvent(Consumer<TaskEvent> onComplete, Result result, LimboPlayer player, RegisteredPlayer playerInfo) {
+ protected PostEvent(Consumer<TaskEvent> onComplete, Result result, LimboPlayer player, RegisteredPlayer playerInfo, String password) {
super(onComplete, result);
this.player = player;
this.playerInfo = playerInfo;
+ this.password = password;
}
public LimboPlayer getPlayer() {
@@ -47,4 +50,8 @@ public abstract class PostEvent extends TaskEvent {
public RegisteredPlayer getPlayerInfo() {
return this.playerInfo;
}
+
+ public String getPassword() {
+ return this.password;
+ }
}
diff --git a/src/main/java/net/elytrium/limboauth/event/PostRegisterEvent.java b/src/main/java/net/elytrium/limboauth/event/PostRegisterEvent.java
index 9c3a6d5..567f1ef 100644
--- a/src/main/java/net/elytrium/limboauth/event/PostRegisterEvent.java
+++ b/src/main/java/net/elytrium/limboauth/event/PostRegisterEvent.java
@@ -23,7 +23,7 @@ import net.elytrium.limboauth.model.RegisteredPlayer;
public class PostRegisterEvent extends PostEvent {
- public PostRegisterEvent(Consumer<TaskEvent> onComplete, LimboPlayer player, RegisteredPlayer playerInfo) {
- super(onComplete, player, playerInfo);
+ public PostRegisterEvent(Consumer<TaskEvent> onComplete, LimboPlayer player, RegisteredPlayer playerInfo, String password) {
+ super(onComplete, player, playerInfo, password);
}
}
diff --git a/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java b/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java
index c8e8f89..6ce39e6 100644
--- a/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java
+++ b/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java
@@ -106,6 +106,7 @@ public class AuthSessionHandler implements LimboSessionHandler {
private String ip;
private int attempts = Settings.IMP.MAIN.LOGIN_ATTEMPTS;
private boolean totpState;
+ private String tempPassword;
public AuthSessionHandler(Dao<RegisteredPlayer, String> playerDao, Player proxyPlayer, LimboAuth plugin, @Nullable RegisteredPlayer playerInfo) {
this.playerDao = playerDao;
@@ -186,12 +187,14 @@ public class AuthSessionHandler implements LimboSessionHandler {
if (args.length != 0 && this.checkArgsLength(args.length)) {
Command command = Command.parse(args[0]);
if (command == Command.REGISTER && !this.totpState && this.playerInfo == null) {
- if (this.checkPasswordsRepeat(args) && this.checkPasswordLength(args[1]) && this.checkPasswordStrength(args[1])) {
+ String password = args[1];
+ if (this.checkPasswordsRepeat(args) && this.checkPasswordLength(password) && this.checkPasswordStrength(password)) {
+ this.saveTempPassword(password);
String username = this.proxyPlayer.getUsername();
RegisteredPlayer registeredPlayer = new RegisteredPlayer(
username,
username.toLowerCase(Locale.ROOT),
- genHash(args[1]),
+ genHash(password),
this.ip,
"",
System.currentTimeMillis(),
@@ -213,7 +216,7 @@ public class AuthSessionHandler implements LimboSessionHandler {
}
this.plugin.getServer().getEventManager()
- .fire(new PostRegisterEvent(this::finishAuth, this.player, this.playerInfo))
+ .fire(new PostRegisterEvent(this::finishAuth, this.player, this.playerInfo, this.tempPassword))
.thenAcceptAsync(this::finishAuth);
}
@@ -223,7 +226,10 @@ public class AuthSessionHandler implements LimboSessionHandler {
// If we don't place {@code return} here, an another message (AuthSessionHandler#sendMessage) will be sent.
return;
} else if (command == Command.LOGIN && !this.totpState && this.playerInfo != null) {
- if (args[1].length() > 0 && checkPassword(args[1], this.playerInfo, this.playerDao)) {
+ String password = args[1];
+ this.saveTempPassword(password);
+
+ if (password.length() > 0 && checkPassword(password, this.playerInfo, this.playerDao)) {
if (this.playerInfo.getTotpToken().isEmpty()) {
this.finishLogin();
} else {
@@ -248,6 +254,10 @@ public class AuthSessionHandler implements LimboSessionHandler {
this.sendMessage(false);
}
+ private void saveTempPassword(String password) {
+ this.tempPassword = password;
+ }
+
@Override
public void onDisconnect() {
if (this.authMainTask != null) {
@@ -322,7 +332,7 @@ public class AuthSessionHandler implements LimboSessionHandler {
}
this.plugin.getServer().getEventManager()
- .fire(new PostAuthorizationEvent(this::finishAuth, this.player, this.playerInfo))
+ .fire(new PostAuthorizationEvent(this::finishAuth, this.player, this.playerInfo, this.tempPassword))
.thenAcceptAsync(this::finishAuth);
}