X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/3c7e3cdc547ad5468421e1c049daa94b0d4b8bc0..761e9780888a343e0655563acea23577eeb5d29a:/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 e4ede79b..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<any>(saveApiToken(apiToken)).finally(
-                        () => dispatch(navigateToRootProject));
+                        () => rdUrl === '/' ? dispatch(navigateToRootProject) : dispatch(replace(rdUrl))
+                    );
                 } else {
                     setError(true);
                     setHelperText(response.data.message || 'Please try again');
@@ -98,7 +102,7 @@ export const LoginForm = withStyles(styles)(
             .catch((err) => {
                 setError(true);
                 setSubmitting(false);
-                setHelperText(`${err.response && err.response.data && err.response.data.errors[0] || 'Error logging in: '+err}`);
+                setHelperText(`${(err.response && err.response.data && err.response.data.errors[0]) || 'Error logging in: '+err}`);
                 setFocus();
             });
         };
