Skip to content

Commit

Permalink
fix: auth handler desync across bukkit servers
Browse files Browse the repository at this point in the history
  • Loading branch information
DirtyConcept committed Jul 23, 2024
1 parent c58124c commit 391f95e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@ public class BasicAuthCommunication extends AuthCommunicationHandler {

private final TwoFactorAuthentication plugin;

private final AuthHandler authHandler;
private AuthHandler authHandler;

public BasicAuthCommunication(TwoFactorAuthentication plugin) {
this.plugin = plugin;
}

this.authHandler = new AuthHandler() {
@Override
public void changeState(@NotNull UUID uuid, @NotNull AuthState authState) {
super.authStates.put(uuid, authState);
}
};
public void loadTimeoutAndHandler(AuthHandler authHandler) {
this.authHandler = authHandler;

long timeout = this.plugin.getConfigHandler().getCommunicationTimeout();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ public AuthHandler(@NotNull TwoFactorAuthentication plugin, @Nullable StorageHan

for(Player pl : Bukkit.getOnlinePlayers())
removeQRItem(pl);

// we pass the auth handler to the communication handler, so we'd have them both synchronized.
// Terrible practice the way I do it because I think sometimes it sets the auth state multiple times
// but this serves as a quick fix for the issue now that I figured it out.
if (authCommunicationHandler instanceof BasicAuthCommunication basicAuth) {
basicAuth.loadTimeoutAndHandler(this);
}
}

public void reloadOnlinePlayers() {
Expand Down

0 comments on commit 391f95e

Please sign in to comment.