AMBARI-7165 When pasting in a url that requires login, login should redirect after login. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/71ef2f1d Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/71ef2f1d Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/71ef2f1d Branch: refs/heads/branch-alerts-dev Commit: 71ef2f1d19a8cef3e79793c39389482e59f6fa0c Parents: 6c651f6 Author: atkach <atk...@hortonworks.com> Authored: Fri Sep 5 12:53:34 2014 +0300 Committer: atkach <atk...@hortonworks.com> Committed: Fri Sep 5 12:53:34 2014 +0300 ---------------------------------------------------------------------- ambari-web/app/router.js | 17 +++++++++++++---- ambari-web/app/routes/main.js | 5 +++-- 2 files changed, 16 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/71ef2f1d/ambari-web/app/router.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/router.js b/ambari-web/app/router.js index 15d269c..e9a965f 100644 --- a/ambari-web/app/router.js +++ b/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); http://git-wip-us.apache.org/repos/asf/ambari/blob/71ef2f1d/ambari-web/app/routes/main.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/main.js b/ambari-web/app/routes/main.js index 057b836..7a39aed 100644 --- a/ambari-web/app/routes/main.js +++ b/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'); });