Browse Source

AMBARI-5283 Check bad credentials vs. aborted and present different message to user on login (ababiichuk)

aBabiichuk 11 years ago
parent
commit
a42d8ca885

+ 6 - 3
ambari-web/app/controllers/login_controller.js

@@ -35,10 +35,13 @@ App.LoginController = Em.Object.extend({
     App.get('router').login();
   },
 
-  postLogin: function (isAuthenticated) {
-    if (!isAuthenticated) {
+  postLogin: function (isConnected, isAuthenticated) {
+    if (!isConnected) {
+      console.log('Failed to connect to Ambari Server');
+      this.set('errorMessage', Em.I18n.t('login.error.bad.connection'));
+    } else if (!isAuthenticated) {
       console.log('Failed to login as: ' + this.get('loginName'));
-      this.set('errorMessage', Em.I18n.t('login.error'));
+      this.set('errorMessage', Em.I18n.t('login.error.bad.credentials'));
     }
   }
 

+ 2 - 1
ambari-web/app/messages.js

@@ -259,7 +259,8 @@ Em.I18n.translations = {
   'login.header':'Sign in',
   'login.username':'Username',
   'login.loginButton':'Sign in',
-  'login.error':'Invalid username/password combination.',
+  'login.error.bad.credentials':'Unable to sign in. Invalid username/password combination.',
+  'login.error.bad.connection':'Unable to connect to Ambari Server. Confirm Ambari Server is running and you can reach Ambari Server from this machine.',
 
   'graphs.noData.title': 'No Data',
   'graphs.noData.message': 'There was no data available. Possible reasons include inaccessible Ganglia service.',

+ 8 - 3
ambari-web/app/router.js

@@ -195,7 +195,7 @@ App.Router = Em.Router.extend({
       App.usersMapper.map({"items": [data]});
       this.setUser(App.User.find(params.loginName));
       this.transitionTo(this.getSection());
-      controller.postLogin(true);
+      controller.postLogin(true,true);
     }
     else {
       App.ajax.send({
@@ -215,7 +215,12 @@ App.Router = Em.Router.extend({
     var controller = this.get('loginController');
     console.log("login error: " + error);
     this.setAuthenticated(false);
-    controller.postLogin(false);
+    if (request.status == 403) {
+      controller.postLogin(true, false);
+    } else {
+      controller.postLogin(false, false);
+    }
+
   },
 
   login2SuccessCallback: function (clusterResp, opt, params) {
@@ -226,7 +231,7 @@ App.Router = Em.Router.extend({
       App.usersMapper.map({"items": [params.loginData]});
       this.setUser(App.User.find(params.loginName));
       this.transitionTo(this.getSection());
-      controller.postLogin(true);
+      controller.postLogin(true,true);
     }
     else {
       controller.set('errorMessage', Em.I18n.t('router.hadoopClusterNotSetUp'));