volatile connection
Some checks failed
Run tests / test-runner (push) Has been cancelled

This commit is contained in:
Jan Prochazka 2024-08-02 16:39:07 +02:00
parent a6822dd293
commit 25fb3b71ca
3 changed files with 14 additions and 4 deletions

View File

@ -243,12 +243,13 @@ module.exports = {
},
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 res = {
...old,
_id: crypto.randomUUID(),
password,
accessToken,
passwordMode: undefined,
unsaved: true,
};
@ -397,7 +398,9 @@ module.exports = {
async dbloginToken({ code, conid, redirectUri }) {
const connection = await this.getCore({ conid });
const driver = requireEngineDriver(connection);
const token = await driver.getAuthTokenFromCode(connection, { code, redirectUri });
console.log('******************************** WE HAVE ACCESS TOKEN', token);
const accessToken = await driver.getAuthTokenFromCode(connection, { code, redirectUri });
const volatile = await this.saveVolatile({ conid, accessToken });
console.log('******************************** WE HAVE ACCESS TOKEN', accessToken);
socket.emit('got-volatile-token', { conid, volatileConId: volatile._id });
},
};

View File

@ -14,7 +14,7 @@
// import { shouldWaitForElectronInitialize } from './utility/getElectron';
import { subscribeConnectionPingers } from './utility/connectionsPinger';
import { subscribePermissionCompiler } from './utility/hasPermission';
import { apiCall } from './utility/api';
import { apiCall, installNewVolatileConnectionListener } from './utility/api';
import { getConfig, getSettings, getUsedApps } from './utility/metadataLoaders';
import AppTitleProvider from './utility/AppTitleProvider.svelte';
import getElectron from './utility/getElectron';
@ -48,6 +48,7 @@
subscribeApiDependendStores();
subscribeConnectionPingers();
subscribePermissionCompiler();
installNewVolatileConnectionListener();
}
loadedApi = loadedApiValue;

View File

@ -223,6 +223,12 @@ export function getVolatileConnections() {
return Object.values(volatileConnectionMap);
}
export function installNewVolatileConnectionListener() {
apiOn('got-volatile-token', ({ conid, volatileConId }) => {
setVolatileConnectionRemapping(conid, volatileConId);
});
}
function enableApiLog() {
apiLogging = true;
console.log('API loggin enabled');