show storage connection error

This commit is contained in:
SPRINX0\prochazka
2024-10-17 11:56:24 +02:00
parent 39b99ecf8f
commit ec3c224f44
3 changed files with 24 additions and 5 deletions

View File

@@ -17,6 +17,7 @@ const { checkLicense, checkLicenseKey } = require('../utility/checkLicense');
const storage = require('./storage'); const storage = require('./storage');
const { getAuthProxyUrl } = require('../utility/authProxy'); const { getAuthProxyUrl } = require('../utility/authProxy');
const { getPublicHardwareFingerprint } = require('../utility/hardwareFingerprint'); const { getPublicHardwareFingerprint } = require('../utility/hardwareFingerprint');
const { extractErrorMessage } = require('dbgate-tools');
const lock = new AsyncLock(); const lock = new AsyncLock();
@@ -39,10 +40,12 @@ module.exports = {
const isUserLoggedIn = authProvider.isUserLoggedIn(req); const isUserLoggedIn = authProvider.isUserLoggedIn(req);
const singleConid = authProvider.getSingleConnectionId(req); const singleConid = authProvider.getSingleConnectionId(req);
const storageConnectionError = storage.getStorageConnectionError();
const singleConnection = singleConid const singleConnection =
? await connections.getCore({ conid: singleConid }) singleConid && !storageConnectionError
: connections.singleConnection; ? await connections.getCore({ conid: singleConid })
: connections.singleConnection;
let configurationError = null; let configurationError = null;
if (process.env.STORAGE_DATABASE && process.env.BASIC_AUTH) { if (process.env.STORAGE_DATABASE && process.env.BASIC_AUTH) {
@@ -50,8 +53,13 @@ module.exports = {
'Basic authentization is not allowed, when using storage. Cannot use both STORAGE_DATABASE and BASIC_AUTH'; 'Basic authentization is not allowed, when using storage. Cannot use both STORAGE_DATABASE and BASIC_AUTH';
} }
const checkedLicense = await checkLicense(); if (storageConnectionError && !configurationError) {
configurationError = extractErrorMessage(storageConnectionError);
}
const checkedLicense = storageConnectionError ? null : await checkLicense();
const isLicenseValid = checkedLicense?.status == 'ok'; const isLicenseValid = checkedLicense?.status == 'ok';
const logoutUrl = storageConnectionError ? null : await authProvider.getLogoutUrl();
return { return {
runAsPortal: !!connections.portalConnections, runAsPortal: !!connections.portalConnections,
@@ -68,7 +76,7 @@ module.exports = {
trialDaysLeft: checkedLicense?.isGeneratedTrial && !checkedLicense?.isExpired ? checkedLicense?.daysLeft : null, trialDaysLeft: checkedLicense?.isGeneratedTrial && !checkedLicense?.isExpired ? checkedLicense?.daysLeft : null,
checkedLicense, checkedLicense,
configurationError, configurationError,
logoutUrl: await authProvider.getLogoutUrl(), logoutUrl,
permissions, permissions,
login, login,
// ...additionalConfigProps, // ...additionalConfigProps,

View File

@@ -17,4 +17,8 @@ module.exports = {
async getConnectionsForLoginPage() { async getConnectionsForLoginPage() {
return null; return null;
}, },
getStorageConnectionError() {
return null;
}
}; };

View File

@@ -125,6 +125,13 @@
} }
internalRedirectTo(`/not-logged.html`); internalRedirectTo(`/not-logged.html`);
} }
$: {
if ($config?.configurationError) {
console.log('Configuration error', $config);
internalRedirectTo(`/error.html`);
}
}
</script> </script>
<div class="root theme-light theme-type-light"> <div class="root theme-light theme-type-light">