Permission system now provides a default player
The default player has a fixed name and uuid that should never collide with existing players. It will never have self permission data, and it will always be part of the default groups. It is useful for anonymous permission test (for instance, listing only the servers that are publicly visible for the ping server list)
This commit is contained in:
@@ -26,6 +26,12 @@ import fr.pandacube.lib.util.Log;
|
||||
/* package */ PermissionsCachedBackendReader() throws DBException {
|
||||
clearAndResetCache();
|
||||
}
|
||||
|
||||
|
||||
/* package */ static final CachedPlayer DEFAULT_PLAYER = new CachedPlayer(DefaultPlayer.ID, null, null, Map.of());
|
||||
static {
|
||||
DEFAULT_PLAYER.usingDefaultGroups = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -58,6 +64,8 @@ import fr.pandacube.lib.util.Log;
|
||||
}
|
||||
|
||||
private CachedPlayer initPlayer(UUID playerId) throws DBException {
|
||||
if (playerId.equals(DEFAULT_PLAYER.playerId))
|
||||
return DEFAULT_PLAYER;
|
||||
|
||||
SQLElementList<SQLPermissions> playerData = DB.getAll(SQLPermissions.class,
|
||||
SQLPermissions.type.eq(EntityType.User.getCode())
|
||||
@@ -196,6 +204,8 @@ import fr.pandacube.lib.util.Log;
|
||||
cacheIsUpdating = false;
|
||||
usersCache.invalidateAll();
|
||||
fullPermissionsList = newFullPermissionsList;
|
||||
DEFAULT_PLAYER.groups.clear();
|
||||
DEFAULT_PLAYER.groups.addAll(getDefaultGroups());
|
||||
}
|
||||
} finally {
|
||||
synchronized (this) {
|
||||
|
Reference in New Issue
Block a user