mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 16:36:00 +00:00
SYNC: dbgate cloud redirect workflow
This commit is contained in:
committed by
Diflow
parent
bd88b8411e
commit
eba16cc15d
@@ -3,6 +3,7 @@ import { getConfig } from './utility/metadataLoaders';
|
||||
import { isAdminPage } from './utility/pageDefs';
|
||||
import getElectron from './utility/getElectron';
|
||||
import { isProApp } from './utility/proTools';
|
||||
import { cloudSigninTokenHolder, selectedWidget } from './stores';
|
||||
|
||||
export function isOauthCallback() {
|
||||
const params = new URLSearchParams(location.search);
|
||||
@@ -114,6 +115,12 @@ export function handleOauthCallback() {
|
||||
return true;
|
||||
}
|
||||
|
||||
const cloudSid = params.get('dbgate-cloud-sid');
|
||||
if (cloudSid) {
|
||||
sessionStorage.setItem('dbgate-cloud-sid', cloudSid);
|
||||
internalRedirectTo(`/`);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -187,6 +194,18 @@ export async function handleAuthOnStartup(config) {
|
||||
}
|
||||
}
|
||||
|
||||
async function checkDbGateCloudLogin() {
|
||||
const sid = sessionStorage.getItem('dbgate-cloud-sid');
|
||||
if (sid) {
|
||||
const tokenHolder = await apiCall('auth/cloud-login-redirected', { sid });
|
||||
if (tokenHolder) {
|
||||
sessionStorage.removeItem('dbgate-cloud-sid');
|
||||
cloudSigninTokenHolder.set(tokenHolder);
|
||||
selectedWidget.set('cloud-private');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (page == 'error') return;
|
||||
if (checkConfigError()) return;
|
||||
|
||||
@@ -199,6 +218,7 @@ export async function handleAuthOnStartup(config) {
|
||||
if (page == 'license' || page == 'admin-license') return;
|
||||
if (checkTrialDaysLeft()) return;
|
||||
if (checkInvalidLicense()) return;
|
||||
checkDbGateCloudLogin();
|
||||
|
||||
// if (config.configurationError) {
|
||||
// internalRedirectTo(`/error.html`);
|
||||
|
||||
Reference in New Issue
Block a user