Repository: ambari Updated Branches: refs/heads/trunk 285539424 -> 2915a9a34
AMBARI-14243. FE: Show message on login page if authentication failed Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/dcaaca2e Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/dcaaca2e Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/dcaaca2e Branch: refs/heads/trunk Commit: dcaaca2ea87cd5bed4a44730f446de443349a92a Parents: 2855394 Author: Alex Antonenko <[email protected]> Authored: Mon Dec 7 12:34:23 2015 +0200 Committer: Alex Antonenko <[email protected]> Committed: Mon Dec 7 12:34:23 2015 +0200 ---------------------------------------------------------------------- ambari-web/app/controllers/login_controller.js | 4 ++-- ambari-web/app/router.js | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/dcaaca2e/ambari-web/app/controllers/login_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/login_controller.js b/ambari-web/app/controllers/login_controller.js index a3b8e32..fc64a54 100644 --- a/ambari-web/app/controllers/login_controller.js +++ b/ambari-web/app/controllers/login_controller.js @@ -37,7 +37,7 @@ App.LoginController = Em.Object.extend({ postLogin: function (isConnected, isAuthenticated, responseText) { if (!isConnected) { - this.set('errorMessage', Em.I18n.t('login.error.bad.connection')); + this.set('errorMessage', responseText || Em.I18n.t('login.error.bad.connection')); } else if (!isAuthenticated) { var errorMessage = ""; if( responseText === "User is disabled" ){ @@ -51,4 +51,4 @@ App.LoginController = Em.Object.extend({ this.set('isSubmitDisabled', false); } -}); \ No newline at end of file +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/dcaaca2e/ambari-web/app/router.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/router.js b/ambari-web/app/router.js index 0df7485..7bd3a58 100644 --- a/ambari-web/app/router.js +++ b/ambari-web/app/router.js @@ -221,6 +221,9 @@ App.Router = Em.Router.extend({ } finally { this.setAuthenticated(false); } + } else if (data.status >= 500) { + this.setAuthenticated(false); + this.loginErrorCallback(data); } }, @@ -331,12 +334,16 @@ App.Router = Em.Router.extend({ loginErrorCallback: function(request) { var controller = this.get('loginController'); this.setAuthenticated(false); - if (request.status == 403) { + if (request.status > 400) { var responseMessage = request.responseText; try{ responseMessage = JSON.parse(request.responseText).message; }catch(e){} + } + if (request.status == 403) { controller.postLogin(true, false, responseMessage); + } else if (request.status == 500) { + controller.postLogin(false, false, responseMessage); } else { controller.postLogin(false, false, null); }
