Skip to content

Commit

Permalink
fix(core.gbapp): FIX SSR errors and setOption impersonated.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Jul 26, 2023
1 parent 19e1292 commit e596f31
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
24 changes: 19 additions & 5 deletions packages/basic.gblib/services/DialogKeywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,19 +557,33 @@ export class DialogKeywords {
// throw new Error(`Not possible to define ${name} as it is a reserved system param name.`);
// }
let { min, user, params } = await DialogKeywords.getProcessInfo(pid);
const sec = new SecService();
await sec.setParam(user.userId, name , value);
GBLog.info(`BASIC: ${name} = ${value} (botId: ${min.botId})`);
return { min, user, params };
const sec = new SecService();
if (user)
{
await sec.setParam(user.userId, name , value);
return { min, user, params };
}
else
{
min[name] = value;
}
}

public static async getOption({ pid, name }) {
if (this.isUserSystemParam(name)) {
throw new Error(`Not possible to retrieve ${name} system param.`);
}
let { min, user, params } = await DialogKeywords.getProcessInfo(pid);
const sec = new SecService();
return await sec.getParam(user, name);

if (user){
const sec = new SecService();
return await sec.getParam(user, name);
}
else
{
return min[name];
}
}

/**
Expand Down
12 changes: 8 additions & 4 deletions packages/core.gbapp/services/GBSSR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,14 @@ export class GBSSR {
// Tries to find botId from URL.

const minBoot = GBServer.globals.minBoot;
let botId =
req.originalUrl && req.originalUrl === '/' ?
minBoot.botId :
/\/([A-Za-z0-9\-\_]+)\/*/.exec(req.originalUrl)[1]
let botId = minBoot.botId;
if (req.originalUrl && req.originalUrl === '/') {
let tmp = /\/([A-Za-z0-9\-\_]+)\/*/.exec(req.originalUrl);
if (tmp) {
botId = tmp[1];
}
}

let min: GBMinInstance =
req.url === '/'
? minBoot
Expand Down

0 comments on commit e596f31

Please sign in to comment.