revokeHostAccess method

void revokeHostAccess(
  1. String userId,
  2. String hostId
)

userId lost the capability terminal on host hostId (04 8.2, 24 8.3): the personal access.changed with the host in removed, and every open session of the person there ends with access_revoked.

Implementation

void revokeHostAccess(String userId, String hostId) {
  permissionVersion++;
  append(
    'access.changed',
    resource: {'kind': 'principal', 'id': userId},
    payload: {
      'permission_version': permissionVersion,
      'added': <Object?>[],
      'removed': [
        {'kind': 'host', 'id': hostId},
      ],
      'changed': <Object?>[],
    },
    audience: userId,
  );
  for (final s in terminal.sessions.values.toList()) {
    if (s.userId == userId && s.hostId == hostId) {
      endTerminalSession(s, 'access_revoked');
    }
  }
}