[bug] Fix crash with unknown tenant

This commit is contained in:
Sergey Konovalov
2022-09-13 18:57:50 +03:00
committed by catbasilio
parent c0f1327bf6
commit c1985c6c97
2 changed files with 24 additions and 13 deletions

View File

@ -1354,7 +1354,13 @@ exports.install = function(server, callbackFunction) {
yield encryptPasswordParams(ctx, data);
switch (data.type) {
case 'auth' :
yield* auth(ctx, conn, data);
try {
yield* auth(ctx, conn, data);
} catch(err){
ctx.logger.error('auth error: %s', err.stack);
conn.close(constants.ACCESS_DENIED_CODE, constants.ACCESS_DENIED_REASON);
return;
}
break;
case 'message' :
yield* onMessage(ctx, conn, data);

View File

@ -171,19 +171,24 @@ docsCoServer.install(server, () => {
app.get('/index.html', (req, res) => {
return co(function*() {
let ctx = new operationContext.Context();
ctx.initFromRequest(req);
let licenseInfo = yield tenantManager.getTenantLicense(ctx);
let buildVersion = commonDefines.buildVersion;
let buildNumber = commonDefines.buildNumber;
let buildDate, packageType, customerId = "";
if (licenseInfo) {
buildDate = licenseInfo.buildDate.toISOString();
packageType = licenseInfo.packageType;
customerId = licenseInfo.customerId;
try {
ctx.initFromRequest(req);
let licenseInfo = yield tenantManager.getTenantLicense(ctx);
let buildVersion = commonDefines.buildVersion;
let buildNumber = commonDefines.buildNumber;
let buildDate, packageType, customerId = "";
if (licenseInfo) {
buildDate = licenseInfo.buildDate.toISOString();
packageType = licenseInfo.packageType;
customerId = licenseInfo.customerId;
}
let output = `Server is functioning normally. Version: ${buildVersion}. Build: ${buildNumber}`;
output += `. Release date: ${buildDate}. Package type: ${packageType}. Customer Id: ${customerId}`;
res.send(output);
} catch (err) {
ctx.logger.error('index.html error: %s', err.stack);
res.sendStatus(400);
}
let output = `Server is functioning normally. Version: ${buildVersion}. Build: ${buildNumber}`;
output += `. Release date: ${buildDate}. Package type: ${packageType}. Customer Id: ${customerId}`;
res.send(output);
});
});
const rawFileParser = bodyParser.raw(