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;
}
getSingleConnection(req) {
getSingleConnectionId(req) {
return null;
}
}

View File

@ -34,12 +34,16 @@ module.exports = {
const isLoginForm = authProvider.isLoginForm();
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 {
runAsPortal: !!connections.portalConnections,
singleDbConnection: connections.singleDbConnection,
singleConnection: connections.singleConnection,
singleConnection: singleConnection,
// hideAppEditor: !!process.env.HIDE_APP_EDITOR,
allowShellConnection: platformInfo.allowShellConnection,
allowShellScripting: platformInfo.allowShellScripting,

View File

@ -414,11 +414,17 @@ module.exports = {
dbloginAuth_meta: true,
async dbloginAuth({ conid, user, password }) {
const saveResp = await this.saveVolatile({ conid, user, password, test: true });
if (saveResp.msgtype == 'connected') {
const loginResp = await getAuthProvider().login(user, password, { conid: saveResp._id });
return loginResp;
if (user || password) {
const saveResp = await this.saveVolatile({ conid, user, password, test: true });
if (saveResp.msgtype == 'connected') {
const loginResp = await getAuthProvider().login(user, password, { conid: saveResp._id });
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 {
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 config = getCurrentConfig();
const conidArray = [...value];
if (getCurrentConfig().storageDatabase && hasPermission('internal-storage')) {
if (config.storageDatabase && hasPermission('internal-storage')) {
conidArray.push('__storage');
}
conidArray.push(...getVolatileConnections());
if (config.singleConnection) {
conidArray.push(config.singleConnection._id);
}
apiCall('server-connections/ping', {
conidArray,
@ -51,4 +56,4 @@ export function subscribeConnectionPingers() {
export function callServerPing() {
const connections = getOpenedConnections();
doServerPing(connections);
}
}