Don't send access unless needed

This commit is contained in:
Colin McDonald 2016-06-26 19:25:42 -04:00
parent 8d66bd1568
commit 95d8a45d86

View File

@ -255,7 +255,6 @@ public final class User {
List<Rank> ranks = getRanksScoped(serverGroup, grants); List<Rank> ranks = getRanksScoped(serverGroup, grants);
result.put("user", this); result.put("user", this);
result.put("access", accessInfo);
result.put("bestRank", ranks.get(0).getId()); result.put("bestRank", ranks.get(0).getId());
result.put("ranks", ranks.stream().map(Rank::getId).collect(Collectors.toList())); result.put("ranks", ranks.stream().map(Rank::getId).collect(Collectors.toList()));
result.put("totpSetup", getTotpSecret() != null); result.put("totpSetup", getTotpSecret() != null);
@ -264,6 +263,10 @@ public final class User {
result.put("mute", activeMute); result.put("mute", activeMute);
} }
if (accessInfo != null) {
result.put("access", accessInfo);
}
callback.onResult(result, null); callback.onResult(result, null);
}); });
} }
@ -286,11 +289,6 @@ public final class User {
} }
} }
Map<String, Object> accessAllowed = ImmutableMap.of(
"allowed", true,
"message", ""
);
if (activeBan != null) { if (activeBan != null) {
callback.onResult(ImmutableMap.of( callback.onResult(ImmutableMap.of(
"allowed", false, "allowed", false,
@ -330,15 +328,17 @@ public final class User {
hasPermissionAnywhere(Permissions.BYPASS_VPN_CHECK, (bypass, error) -> { hasPermissionAnywhere(Permissions.BYPASS_VPN_CHECK, (bypass, error) -> {
if (error != null) { if (error != null) {
callback.onResult(null, error); callback.onResult(null, error);
} else if (bypass) {
callback.onResult(null, null);
} else { } else {
callback.onResult(bypass ? accessAllowed : finalProposedAccess, null); callback.onResult(finalProposedAccess, null);
} }
}); });
} else { } else {
callback.onResult(accessAllowed, null); callback.onResult(null, null);
} }
} else { } else {
callback.onResult(accessAllowed, null); callback.onResult(null, null);
} }
} }