[feature] Read user.customerId from open config

This commit is contained in:
Sergey Konovalov
2025-08-14 01:17:39 +03:00
parent 407ea57312
commit 92a97aefce
2 changed files with 17 additions and 4 deletions

View File

@ -536,6 +536,7 @@ function fillJwtByConnection(ctx, conn) {
user.id = conn.user.idOriginal;
user.name = conn.user.username;
user.index = conn.user.indexUser;
user.customerId = conn.user.customerId;
if (conn.coEditingMode) {
edit.coEditing = {mode: conn.coEditingMode};
}
@ -2504,6 +2505,9 @@ exports.install = function(server, callbackFunction) {
//like in Common.Utils.fillUserInfo(web-apps/apps/common/main/lib/util/utils.js)
dataUser.username = user.group.toString() + String.fromCharCode(160) + dataUser.username;
}
if (user.customerId) {
dataUser.customerId = user.customerId;
}
}
if (edit.user && edit.user.name) {
data.denyChangeName = true;
@ -2691,6 +2695,7 @@ exports.install = function(server, callbackFunction) {
id: curUserId,
idOriginal: curUserIdOriginal,
username: fillUsername(ctx, data),
customerId: user.customerId,
indexUser: curIndexUser,
view: !isEditMode(data.permissions, data.mode)
};

View File

@ -174,6 +174,8 @@ async function proxyRequest(req, res) {
let docId = '';
let userId = '';
let userName = '';
let userCustomerId = '';
if (tenTokenEnableBrowser) {
let checkJwtRes = await docsCoServer.checkJwtHeader(ctx, req, 'Authorization', 'Bearer ', commonDefines.c_oAscSecretType.Session);
if (!checkJwtRes || checkJwtRes.err) {
@ -186,8 +188,11 @@ async function proxyRequest(req, res) {
});
return;
} else {
userId = checkJwtRes?.decoded?.editorConfig?.user?.id;
docId = checkJwtRes?.decoded?.document?.key;
userId = checkJwtRes?.decoded?.editorConfig?.user?.id;
userName = checkJwtRes?.decoded?.editorConfig?.user?.name;
userCustomerId = checkJwtRes?.decoded?.editorConfig?.user?.customerId;
ctx.setDocId(docId);
ctx.setUserId(userId);
}
@ -249,10 +254,13 @@ async function proxyRequest(req, res) {
const tenTokenOutboxPrefix = ctx.getCfg('services.CoAuthoring.token.outbox.prefix', cfgTokenOutboxPrefix);
let [licenseInfo] = await tenantManager.getTenantLicense(ctx);
let dataObject = {
const dataObject = {
key: docId,
user: userId,
customer_id: licenseInfo.customerId
user: {
id: userId,
name: userName,
customerId: (userCustomerId || licenseInfo.customerId),
}
}
let secret = await tenantManager.getTenantSecret(ctx, commonDefines.c_oAscSecretType.Outbox);