X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/620d5745b5fb97e08945c15048ad5439e5bbe80c..bbc64c1641d37f8e793a901b93be439e7a8f229e:/src/views-components/login-form/login-form.tsx diff --git a/src/views-components/login-form/login-form.tsx b/src/views-components/login-form/login-form.tsx index aac13642..3aa9e3f2 100644 --- a/src/views-components/login-form/login-form.tsx +++ b/src/views-components/login-form/login-form.tsx @@ -12,6 +12,7 @@ import { AxiosPromise } from 'axios'; import { DispatchProp } from 'react-redux'; import { saveApiToken } from 'store/auth/auth-action'; import { navigateToRootProject } from 'store/navigation/navigation-action'; +import { replace } from 'react-router-redux'; type CssRules = 'root' | 'loginBtn' | 'card' | 'wrapper' | 'progress'; @@ -87,8 +88,11 @@ export const LoginForm = withStyles(styles)( setSubmitting(false); if (response.data.uuid && response.data.api_token) { const apiToken = `v2/${response.data.uuid}/${response.data.api_token}`; + const rd = new URL(window.location.href); + const rdUrl = rd.pathname + rd.search; dispatch(saveApiToken(apiToken)).finally( - () => dispatch(navigateToRootProject)); + () => rdUrl === '/' ? dispatch(navigateToRootProject) : dispatch(replace(rdUrl)) + ); } else { setError(true); setHelperText(response.data.message || 'Please try again');