mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 15:14:52 +09:00
Drop subscriptions when a user loses permission for them
The permission for a subscription was only checked when subscribing, so a control connection kept receiving events after the user's roles or role permissions changed to no longer allow it. Add SubscriptionController.unsubscribeUnpermitted which rechecks every subscription of a link and removes the ones the user is no longer permitted, and call it for the affected control connections from userPermissionsUpdated and rolesUpdated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ce6bfe282f
commit
beec2f523a
4 files changed
+103
No files matched your search
@@ -1086,6 +1086,7 @@ export default class Controller {
|
||||
userPermissionsUpdated(user: Readonly<User>) {
|
||||
for (let controlConnection of this.wsServer.controlConnections.values()) {
|
||||
if (controlConnection.user === user) {
|
||||
this.subscriptions.unsubscribeUnpermitted(controlConnection, user);
|
||||
controlConnection.send(
|
||||
new lib.AccountUpdateEvent([...user.roles].map(r => ({
|
||||
name: r.name,
|
||||
@@ -1104,6 +1105,7 @@ export default class Controller {
|
||||
for (const role of roles) {
|
||||
for (let controlConnection of this.wsServer.controlConnections.values()) {
|
||||
if (controlConnection.user.roles.has(role)) {
|
||||
this.subscriptions.unsubscribeUnpermitted(controlConnection, controlConnection.user);
|
||||
controlConnection.send(
|
||||
new lib.AccountUpdateEvent(
|
||||
[...controlConnection.user.roles].map(r => ({
|
||||
|
||||
Reference in new issue
Block a user