From a4f415a05a4f8163128c96b35221241e456c715f Mon Sep 17 00:00:00 2001 From: yaroslav8765 Date: Fri, 3 Jul 2026 12:10:52 +0300 Subject: [PATCH 1/2] fix: rebuild AdminForth/1781/image --- adminforth/servers/express.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adminforth/servers/express.ts b/adminforth/servers/express.ts index 7240ce1a7..83ea79d0f 100644 --- a/adminforth/servers/express.ts +++ b/adminforth/servers/express.ts @@ -32,7 +32,7 @@ import { createRequire } from 'module'; // instead of a static JSON import (which would hard-link a peer dep at parse time). const require = createRequire(import.meta.url); const expressVersion: string = require('express/package.json').version; - + function replaceAtStart(string, substring) { if (string.startsWith(substring)) { return string.slice(substring.length); From a5fdb89c1bb7c7291e4dd0c0ce387714037257bc Mon Sep 17 00:00:00 2001 From: yaroslav8765 Date: Thu, 30 Jul 2026 18:18:18 +0300 Subject: [PATCH 2/2] fix: add debug logs for the socket brocker AdminForth/1830/ws-authorization-work --- adminforth/dataConnectors/baseConnector.ts | 11 ++++++++--- adminforth/modules/socketBroker.ts | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/adminforth/dataConnectors/baseConnector.ts b/adminforth/dataConnectors/baseConnector.ts index 8128aadce..d95b05a4c 100644 --- a/adminforth/dataConnectors/baseConnector.ts +++ b/adminforth/dataConnectors/baseConnector.ts @@ -25,18 +25,21 @@ type AdminForthFilterNormalizationResult = { }; async function publishShowPageUpdate(resource: AdminForthResource, recordId: string, updates: Record) { - await global.adminforth.websocket.publish(`/showPage/${resource.resourceId}/${String(recordId)}`, - { + await global.adminforth.websocket.publish({ + topic: `/showPage/${resource.resourceId}/${String(recordId)}`, + data: { resourceId: resource.resourceId, recordId, updates, }, - async (adminUser: AdminUser): Promise => { + filterUsers: async (adminUser: AdminUser): Promise => { + console.log(`Checking show access for ${resource.resourceId} record ${recordId} `); if (!adminUser) { // anonymous clients should never receive record updates return false; } try { + console.log(`Checking show access for ${resource.resourceId} record ${recordId}`); const { allowedActions } = await interpretResource( adminUser, resource, @@ -44,12 +47,14 @@ async function publishShowPageUpdate(resource: AdminForthResource, recordId: str ActionCheckSource.ShowRequest, global.adminforth, ); + console.log(`Allowed actions for ${resource.resourceId} record ${recordId} for user: ${JSON.stringify(allowedActions)}`); return allowedActions[AllowedActionsEnum.show] === true; } catch (e) { afLogger.error(`Error while checking show access for ${resource.resourceId} record ${recordId}, assuming update should not be sent: ${e}`); return false; } } + } ); } diff --git a/adminforth/modules/socketBroker.ts b/adminforth/modules/socketBroker.ts index 5b59786e7..23fb194af 100644 --- a/adminforth/modules/socketBroker.ts +++ b/adminforth/modules/socketBroker.ts @@ -154,13 +154,19 @@ export default class SocketBroker implements IWebSocketBroker { } async publish(topic: string, data: any, filterUsers?: (adminUser: AdminUser) => Promise): Promise { + console.log(`_____________________________________________Publishing to topic ${topic} data ${JSON.stringify(data)}`); + console.log("Does filterUsers exist? ", filterUsers ? "Yes" : "No"); if (!this.topics[topic]) { + console.log(`No clients subscribed to topic ${topic}`); afLogger.trace(`No clients subscribed to topic ${topic}`); return; } for (const client of this.topics[topic]) { + console.log(`Sending data to socket ${topic} ${JSON.stringify(data)}`); if (filterUsers) { + console.log(`Filtering users for topic ${topic} ${client.adminUser}`); if (! (await filterUsers(client.adminUser)) ) { + console.log(`Client not authorized to receive message ${topic} ${client.adminUser}`); afLogger.trace(`Client not authorized to receive message ${topic} ${client.adminUser}`); continue; }