Skip to content

Commit

Permalink
adding param to manage SSO redirection (#918)
Browse files Browse the repository at this point in the history
* adding param to manage SSO redirection

* added standalone when not sharing credentials

* Removed superfluous log statements

---------

Co-authored-by: Niels de Jong <[email protected]>
  • Loading branch information
alfredorubin96 and nielsdejong authored Nov 11, 2024
1 parent 1555b81 commit 455ee42
Showing 1 changed file with 7 additions and 29 deletions.
36 changes: 7 additions & 29 deletions src/application/ApplicationThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ export const handleSharedDashboardsThunk = () => (dispatch: any) => {
if (dashboardDatabase) {
dispatch(setStandaloneDashboardDatabase(dashboardDatabase));
}

if (urlParams.get('credentials')) {
setWelcomeScreenOpen(false);
const connection = decodeURIComponent(urlParams.get('credentials'));
Expand All @@ -271,32 +270,6 @@ export const handleSharedDashboardsThunk = () => (dispatch: any) => {
const database = connection.split('@')[1].split(':')[0];

Check warning on line 270 in src/application/ApplicationThunks.ts

View workflow job for this annotation

GitHub Actions / build-test (18.x)

Use array destructuring
const url = connection.split('@')[1].split(':')[1];

Check warning on line 271 in src/application/ApplicationThunks.ts

View workflow job for this annotation

GitHub Actions / build-test (18.x)

Use array destructuring
const port = connection.split('@')[1].split(':')[2];

Check warning on line 272 in src/application/ApplicationThunks.ts

View workflow job for this annotation

GitHub Actions / build-test (18.x)

Use array destructuring
// if (url == password) {
// // Special case where a connect link is generated without a password.
// // Here, the format is parsed incorrectly and we open the connection window instead.
// dispatch(setConnectionProperties(protocol, url, port, database, username.split('@')[0], ''));
// dispatch(
// setShareDetailsFromUrl(
// type,
// id,
// standalone,
// protocol,
// url,
// port,
// database,
// username.split('@')[0],
// '',
// dashboardDatabase,
// true
// )
// );
// setDashboardToLoadAfterConnecting(id);
// window.history.pushState({}, document.title, window.location.pathname);
// dispatch(setConnectionModalOpen(true));
// dispatch(setWelcomeScreenOpen(false));
// // window.history.pushState({}, document.title, "/");
// return;
// }

dispatch(setConnectionModalOpen(false));
dispatch(
Expand Down Expand Up @@ -327,7 +300,7 @@ export const handleSharedDashboardsThunk = () => (dispatch: any) => {
setShareDetailsFromUrl(
type,
id,
undefined,
standalone,
undefined,
undefined,
undefined,
Expand Down Expand Up @@ -385,6 +358,7 @@ export const onConfirmLoadSharedDashboardThunk = () => (dispatch: any, getState:
}
if (shareDetails.standalone == true) {
dispatch(setStandaloneMode(true));
localStorage.setItem('standaloneShared', 'true'); // EDGE CASE: redirect SSO removes the shareDetails when redirecting
}
dispatch(resetShareDetails());
} catch (e) {
Expand Down Expand Up @@ -455,10 +429,13 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
dispatch(setSSOEnabled(config.ssoEnabled, state.application.cachedSSODiscoveryUrl));
dispatch(setSSOProviders(config.ssoProviders));

// Check if we are in standalone mode
// const standaloneShared = localStorage.getItem('standaloneShared') == 'true'; // EDGE case: from url param it could happen that we lose the value due to SSO redirect
const { standalone } = config;
// || standaloneShared;

// if a dashboard database was previously set, remember to use it.
const dashboardDatabase = state.application.standaloneDashboardDatabase;

dispatch(
setStandaloneEnabled(
standalone,
Expand All @@ -478,6 +455,7 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
config.standaloneDatabaseList
)
);
localStorage.removeItem('standaloneShared');

dispatch(setLoggingMode(config.loggingMode));
dispatch(setLoggingDatabase(config.loggingDatabase));
Expand Down

0 comments on commit 455ee42

Please sign in to comment.