]> source.dussan.org Git - sonarqube.git/commitdiff
always redirect to landing after login from about page
authorStas Vilchik <vilchiks@gmail.com>
Tue, 28 Feb 2017 09:08:11 +0000 (10:08 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Tue, 28 Feb 2017 09:08:11 +0000 (10:08 +0100)
server/sonar-web/src/main/js/app/components/nav/global/GlobalNavUser.js

index 1b99b95f7553b60054b44059c9ccfb9e0bf933d4..b8a5fe7c1df529a0b1e48c86c8fbe7a8ea14fbfd 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
+// @flow
 import React from 'react';
 import { Link, withRouter } from 'react-router';
 import Avatar from '../../../../components/ui/Avatar';
 import { translate } from '../../../../helpers/l10n';
 
 class GlobalNavUser extends React.Component {
+  props: {
+    currentUser: {
+      email?: string,
+      name: string
+    },
+    location: Object,
+    router: { push: (string) => void }
+  };
+
   handleLogin = e => {
     e.preventDefault();
-    const returnTo = window.location.pathname + window.location.search;
-    window.location = `${window.baseUrl}/sessions/new?return_to=${encodeURIComponent(returnTo)}${window.location.hash}`;
+    const shouldReturnToCurrentPage = window.location.pathname !== `${window.baseUrl}/about`;
+    if (shouldReturnToCurrentPage) {
+      const returnTo = encodeURIComponent(window.location.pathname + window.location.search);
+      window.location = `${window.baseUrl}/sessions/new?return_to=${returnTo}${window.location.hash}`;
+    } else {
+      window.location = `${window.baseUrl}/sessions/new`;
+    }
   };
 
   handleLogout = e => {