Author: yusaku
Date: Thu Apr 18 01:46:02 2013
New Revision: 1469129
URL: http://svn.apache.org/r1469129
Log:
AMBARI-1959. Cannot login to Ambari after login failure. (yusaku)
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/ambari-web/app/router.js
incubator/ambari/trunk/ambari-web/app/utils/ajax.js
Modified: incubator/ambari/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1469129&r1=1469128&r2=1469129&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Thu Apr 18 01:46:02 2013
@@ -749,6 +749,8 @@ Trunk (unreleased changes):
BUG FIXES
+ AMBARI-1959. Cannot login to Ambari after login failure. (yusaku)
+
AMBARI-1957. Hosts table: whether the alert filter is in effect or not is
not clear. (yusaku)
Modified: incubator/ambari/trunk/ambari-web/app/router.js
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/router.js?rev=1469129&r1=1469128&r2=1469129&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/router.js (original)
+++ incubator/ambari/trunk/ambari-web/app/router.js Thu Apr 18 01:46:02 2013
@@ -88,8 +88,29 @@ App.Router = Em.Router.extend({
getAuthenticated: function () {
var auth = App.db.getAuthenticated();
var authResp = (auth && auth === true);
- this.set('loggedIn', authResp);
- return authResp;
+ if (authResp) {
+ App.ajax.send({
+ name: 'router.authentication',
+ sender: this,
+ success: 'onAuthenticationSuccess',
+ error: 'onAuthenticationError'
+ });
+ } else {
+ this.set('loggedIn', false);
+ }
+ return this.get('loggedIn');
+ },
+
+ onAuthenticationSuccess: function (data) {
+ this.set('loggedIn', true);
+ },
+
+ onAuthenticationError: function (data) {
+ if (data.status === 403) {
+ this.set('loggedIn', false);
+ } else {
+ console.log('error in getAuthenticated');
+ }
},
setAuthenticated: function (authenticated) {
@@ -122,17 +143,6 @@ App.Router = Em.Router.extend({
return App.db.getUser();
},
- resetAuth: function (authenticated) {
- if (!authenticated) {
- App.db.cleanUp();
- this.set('loggedIn', false);
- this.set('loginController.loginName', '');
- this.set('loginController.password', '');
- this.transitionTo('login');
- }
- return authenticated;
- },
-
login: function () {
var controller = this.get('loginController');
var loginName = controller.get('loginName').toLowerCase();
@@ -288,12 +298,13 @@ App.Router = Em.Router.extend({
// since it's a computed property but we are not setting it as a dependent
of App.db.
App.db.cleanUp();
App.set('isAdmin', false);
+ this.set('loggedIn', false);
this.clearAllSteps();
console.log("Log off: " + App.router.getClusterName());
this.set('loginController.loginName', '');
this.set('loginController.password', '');
-
- if (!App.testMode) {
+ // When logOff is called by Sign Out button, context contains event
object. As it is only case we should send logoff request, we are checking
context below.
+ if (!App.testMode && context) {
App.ajax.send({
name: 'router.logoff',
sender: this,
Modified: incubator/ambari/trunk/ambari-web/app/utils/ajax.js
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/utils/ajax.js?rev=1469129&r1=1469128&r2=1469129&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/utils/ajax.js (original)
+++ incubator/ambari/trunk/ambari-web/app/utils/ajax.js Thu Apr 18 01:46:02 2013
@@ -657,7 +657,16 @@ var urls = {
},
'router.login': {
'real': '/users/{loginName}',
- 'mock': '/data/users/user_{usr}.json'
+ 'mock': '/data/users/user_{usr}.json',
+ 'format': function (data, opt) {
+ var statusCode = jQuery.extend({}, require('data/statusCodes'));
+ statusCode['403'] = function () {
+ console.log("Error code 403: Forbidden.");
+ }
+ return {
+ statusCode: statusCode
+ };
+ }
},
'router.login2': {
'real': '/clusters',
@@ -665,6 +674,15 @@ var urls = {
},
'router.logoff': {
'real': '/logout'
+ },
+ 'router.authentication': {
+ 'real': '/clusters',
+ 'mock': '/data/clusters/info.json',
+ 'format': function (data, opt) {
+ return {
+ async: false
+ };
+ }
}
};
/**