Browse Source

AMBARI-7165 When pasting in a url that requires login, login should redirect after login. (atkach)

atkach 10 years ago
parent
commit
71ef2f1d19
2 changed files with 16 additions and 6 deletions
  1. 13 4
      ambari-web/app/router.js
  2. 3 2
      ambari-web/app/routes/main.js

+ 13 - 4
ambari-web/app/router.js

@@ -29,6 +29,10 @@ App.Router = Em.Router.extend({
   enableLogging: true,
   isFwdNavigation: true,
   backBtnForHigherStep: false,
+  /**
+   * user prefered path to route
+   */
+  preferedPath: null,
 
   setNavigationFlow: function (step) {
     var matches = step.match(/\d+$/);
@@ -282,10 +286,15 @@ App.Router = Em.Router.extend({
         }
       }
       if (transitionToApp) {
-        router.getSection(function (route) {
-          router.transitionTo(route);
-          loginController.postLogin(true, true);
-        });
+        if (!Em.isNone(router.get('preferedPath'))) {
+          window.location = router.get('preferedPath');
+          router.set('preferedPath', null);
+        } else {
+          router.getSection(function (route) {
+            router.transitionTo(route);
+            loginController.postLogin(true, true);
+          });
+        }
       } else {
         router.transitionTo('main.views.index');
         loginController.postLogin(true,true);

+ 3 - 2
ambari-web/app/routes/main.js

@@ -45,6 +45,7 @@ module.exports = Em.Route.extend({
         });
         // TODO: redirect to last known state
       } else {
+        router.set('preferedPath', router.location.location.hash);
         Em.run.next(function () {
           router.transitionTo('login');
         });
@@ -89,7 +90,7 @@ module.exports = Em.Route.extend({
       route: '/',
       enter: function (router) {
         Em.run.next(function () {
-          router.transitionTo('widgets');
+          router.transitionTo('main.dashboard.widgets');
         });
       }
     }),
@@ -312,7 +313,7 @@ module.exports = Em.Route.extend({
   admin: Em.Route.extend({
     route: '/admin',
     enter: function (router, transition) {
-      if (!App.isAdmin) {
+      if (router.get('loggeIn') && !App.get('isAdmin')) {
         Em.run.next(function () {
           router.transitionTo('main.dashboard.index');
         });