single connection support

This commit is contained in:
Jan Prochazka 2024-08-06 10:58:18 +02:00
parent 2440d6b75f
commit 5d6d827044
5 changed files with 32 additions and 10 deletions

View File

@ -44,7 +44,7 @@ class AuthProviderBase {
return null; return null;
} }
getSingleConnection(req) { getSingleConnectionId(req) {
return null; return null;
} }
} }

View File

@ -34,12 +34,16 @@ module.exports = {
const isLoginForm = authProvider.isLoginForm(); const isLoginForm = authProvider.isLoginForm();
const additionalConfigProps = authProvider.getAdditionalConfigProps(); const additionalConfigProps = authProvider.getAdditionalConfigProps();
const singleConnection = await authProvider.getSingleConnection(req); const singleConid = authProvider.getSingleConnectionId(req);
const singleConnection = singleConid
? await connections.getCore({ conid: singleConid })
: connections.singleConnection;
return { return {
runAsPortal: !!connections.portalConnections, runAsPortal: !!connections.portalConnections,
singleDbConnection: connections.singleDbConnection, singleDbConnection: connections.singleDbConnection,
singleConnection: connections.singleConnection, singleConnection: singleConnection,
// hideAppEditor: !!process.env.HIDE_APP_EDITOR, // hideAppEditor: !!process.env.HIDE_APP_EDITOR,
allowShellConnection: platformInfo.allowShellConnection, allowShellConnection: platformInfo.allowShellConnection,
allowShellScripting: platformInfo.allowShellScripting, allowShellScripting: platformInfo.allowShellScripting,

View File

@ -414,11 +414,17 @@ module.exports = {
dbloginAuth_meta: true, dbloginAuth_meta: true,
async dbloginAuth({ conid, user, password }) { async dbloginAuth({ conid, user, password }) {
if (user || password) {
const saveResp = await this.saveVolatile({ conid, user, password, test: true }); const saveResp = await this.saveVolatile({ conid, user, password, test: true });
if (saveResp.msgtype == 'connected') { if (saveResp.msgtype == 'connected') {
const loginResp = await getAuthProvider().login(user, password, { conid: saveResp._id }); const loginResp = await getAuthProvider().login(user, password, { conid: saveResp._id });
return loginResp; return loginResp;
} }
return saveResp; return saveResp;
}
// user and password is stored in connection, volatile connection is not needed
const loginResp = await getAuthProvider().login(null, null, { conid });
return loginResp;
}, },
}; };

View File

@ -134,6 +134,13 @@
} else { } else {
sqlConnectResult = resp; sqlConnectResult = resp;
} }
} else {
enableApi();
const resp = await apiCall('connections/dblogin-auth', {
conid: selectedConnection.conid,
});
localStorage.setItem('accessToken', resp.accessToken);
internalRedirectTo('?');
} }
}} }}
/> />

View File

@ -10,11 +10,16 @@ import hasPermission from '../utility/hasPermission';
// }; // };
const doServerPing = value => { const doServerPing = value => {
const config = getCurrentConfig();
const conidArray = [...value]; const conidArray = [...value];
if (getCurrentConfig().storageDatabase && hasPermission('internal-storage')) { if (config.storageDatabase && hasPermission('internal-storage')) {
conidArray.push('__storage'); conidArray.push('__storage');
} }
conidArray.push(...getVolatileConnections()); conidArray.push(...getVolatileConnections());
if (config.singleConnection) {
conidArray.push(config.singleConnection._id);
}
apiCall('server-connections/ping', { apiCall('server-connections/ping', {
conidArray, conidArray,