Skip to content

Commit

Permalink
Merge pull request #10605 from Cattlesquat/10604
Browse files Browse the repository at this point in the history
10604 - Don't match blank passwords so willy nilly
  • Loading branch information
uckelman authored Oct 24, 2021
2 parents e027099 + e228ea8 commit fbf7727
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@ public static String getMyLocalizedSide() {
protected static List<String> getCurrentPasswords() {
return List.of(
GameModule.getUserId(),
Resources.getString("Prefs.password_prompt", System.getProperty("user.name")),
""
Resources.getString("Prefs.password_prompt", System.getProperty("user.name"))
);
}

Expand Down Expand Up @@ -548,13 +547,26 @@ protected void claimOccupiedSide() {

if (r != null) {
int index = 0;

// First check for passwords that either (a) precisely match our actual *current* password, or (b) match our non-blank default password
for (final PlayerInfo pi : r.getPlayers()) {
if (pwdsToMatch.contains(pi.playerId)) {
allowedSides.add(pi);
indices.add(index);
}
index++;
}

// Only if we don't match *any* of those do we try auto-matching a blank password, and then only for non-observer slots
if (index == 0) {
for (final PlayerInfo pi : r.getPlayers()) {
if ("".equals(pi.playerId) && !OBSERVER.equals(pi.getSide())) {
allowedSides.add(pi);
indices.add(index);
}
index++;
}
}
}

GameModule.setTempUserId(null);
Expand Down

0 comments on commit fbf7727

Please sign in to comment.