mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 16:43:59 +00:00
volatile connection
This commit is contained in:
@@ -243,12 +243,13 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
saveVolatile_meta: true,
|
saveVolatile_meta: true,
|
||||||
async saveVolatile({ conid, user, password, test }) {
|
async saveVolatile({ conid, user = undefined, password = undefined, accessToken = undefined, test = false }) {
|
||||||
const old = await this.getCore({ conid });
|
const old = await this.getCore({ conid });
|
||||||
const res = {
|
const res = {
|
||||||
...old,
|
...old,
|
||||||
_id: crypto.randomUUID(),
|
_id: crypto.randomUUID(),
|
||||||
password,
|
password,
|
||||||
|
accessToken,
|
||||||
passwordMode: undefined,
|
passwordMode: undefined,
|
||||||
unsaved: true,
|
unsaved: true,
|
||||||
};
|
};
|
||||||
@@ -397,7 +398,9 @@ module.exports = {
|
|||||||
async dbloginToken({ code, conid, redirectUri }) {
|
async dbloginToken({ code, conid, redirectUri }) {
|
||||||
const connection = await this.getCore({ conid });
|
const connection = await this.getCore({ conid });
|
||||||
const driver = requireEngineDriver(connection);
|
const driver = requireEngineDriver(connection);
|
||||||
const token = await driver.getAuthTokenFromCode(connection, { code, redirectUri });
|
const accessToken = await driver.getAuthTokenFromCode(connection, { code, redirectUri });
|
||||||
console.log('******************************** WE HAVE ACCESS TOKEN', token);
|
const volatile = await this.saveVolatile({ conid, accessToken });
|
||||||
|
console.log('******************************** WE HAVE ACCESS TOKEN', accessToken);
|
||||||
|
socket.emit('got-volatile-token', { conid, volatileConId: volatile._id });
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
// import { shouldWaitForElectronInitialize } from './utility/getElectron';
|
// import { shouldWaitForElectronInitialize } from './utility/getElectron';
|
||||||
import { subscribeConnectionPingers } from './utility/connectionsPinger';
|
import { subscribeConnectionPingers } from './utility/connectionsPinger';
|
||||||
import { subscribePermissionCompiler } from './utility/hasPermission';
|
import { subscribePermissionCompiler } from './utility/hasPermission';
|
||||||
import { apiCall } from './utility/api';
|
import { apiCall, installNewVolatileConnectionListener } from './utility/api';
|
||||||
import { getConfig, getSettings, getUsedApps } from './utility/metadataLoaders';
|
import { getConfig, getSettings, getUsedApps } from './utility/metadataLoaders';
|
||||||
import AppTitleProvider from './utility/AppTitleProvider.svelte';
|
import AppTitleProvider from './utility/AppTitleProvider.svelte';
|
||||||
import getElectron from './utility/getElectron';
|
import getElectron from './utility/getElectron';
|
||||||
@@ -48,6 +48,7 @@
|
|||||||
subscribeApiDependendStores();
|
subscribeApiDependendStores();
|
||||||
subscribeConnectionPingers();
|
subscribeConnectionPingers();
|
||||||
subscribePermissionCompiler();
|
subscribePermissionCompiler();
|
||||||
|
installNewVolatileConnectionListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
loadedApi = loadedApiValue;
|
loadedApi = loadedApiValue;
|
||||||
|
|||||||
@@ -223,6 +223,12 @@ export function getVolatileConnections() {
|
|||||||
return Object.values(volatileConnectionMap);
|
return Object.values(volatileConnectionMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function installNewVolatileConnectionListener() {
|
||||||
|
apiOn('got-volatile-token', ({ conid, volatileConId }) => {
|
||||||
|
setVolatileConnectionRemapping(conid, volatileConId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function enableApiLog() {
|
function enableApiLog() {
|
||||||
apiLogging = true;
|
apiLogging = true;
|
||||||
console.log('API loggin enabled');
|
console.log('API loggin enabled');
|
||||||
|
|||||||
Reference in New Issue
Block a user