From 99e741e22b09922c8780caa41040747ea981d9e6 Mon Sep 17 00:00:00 2001 From: Maks <41080668+Maks19@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:43:07 +0200 Subject: [PATCH] [SALAD-23183] WebApp - Redirect to Demand Alerts Page on successful login (#1240) --- packages/web-app/src/modules/auth/AuthStore.tsx | 4 ++-- .../DemandMonitorPage/DemandMonitorPageContainer.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/web-app/src/modules/auth/AuthStore.tsx b/packages/web-app/src/modules/auth/AuthStore.tsx index c0c9dbd17..e9199b689 100644 --- a/packages/web-app/src/modules/auth/AuthStore.tsx +++ b/packages/web-app/src/modules/auth/AuthStore.tsx @@ -36,12 +36,12 @@ export class AuthStore { } @action - public login = async (): Promise => { + public login = async (redirectUri?: string): Promise => { // Don't do anything if we are already logged in try { await this.axios.get('/api/v1/profile').then(() => runInAction(() => (this.isAuthenticated = true))) } catch { - const routeWithoutTrailingSlash = this.store.routing.location.pathname.slice(1) + const routeWithoutTrailingSlash = redirectUri ?? this.store.routing.location.pathname.slice(1) window.location.assign(`${config.loginUrl}?redirect_uri=${routeWithoutTrailingSlash}`) } diff --git a/packages/web-app/src/modules/demand-monitor-views/DemandMonitorPage/DemandMonitorPageContainer.tsx b/packages/web-app/src/modules/demand-monitor-views/DemandMonitorPage/DemandMonitorPageContainer.tsx index a5a4bd244..2c00795ff 100644 --- a/packages/web-app/src/modules/demand-monitor-views/DemandMonitorPage/DemandMonitorPageContainer.tsx +++ b/packages/web-app/src/modules/demand-monitor-views/DemandMonitorPage/DemandMonitorPageContainer.tsx @@ -19,7 +19,7 @@ export const _DemandMonitorPageContainer: FC = ({ isAuth const mapStoreToProps = (store: RootStore): any => ({ onLoginClick: () => { store.analytics.trackButtonClicked('login_button', 'Log In Button', 'enabled') - store.auth.login() + store.auth.login('/account/alerts') }, fetchDemandedHardwarePerformanceList: store.demandMonitor.fetchDemandedHardwarePerformanceList, navigateToDemandAlerts: () => store.routing.push('/account/alerts'),