var RcmLoginMgr = function(loginUrl) {

    var me = this;

    me.loginUrl = loginUrl;

    me.successCallback = null;

    me.failCallback = null;

    me.doLogin = function(username, password, successCallback, failCallback) {

        me.successCallback=successCallback;
        me.failCallback=failCallback;

        var data = {
            username : username,
            password :  password
        };

        $.ajax({
            type: 'POST',
            url : me.loginUrl,
            cache : false,
            data : data,
            dataType: "json",
            success : me.processResponse,
            error : function(){me.callFail('systemFailure');}
        });
    };

    me.processResponse = function(data) {
        if(!data.dataOk) {
            if (!data.error) {
                me.doSystemFailure(data);
                return
            }

            me.processError(data.error);
            return;
        }

        me.doSuccess(data);
    };

    me.processError = function(error) {
        switch(error) {
            case 'missingNeeded':
                me.callFail('missing');
                break;
            case 'invalid':
                me.callFail('invalid');
                break;
            case 'noAuth':
                me.callFail('invalid');
                break;
            default:
                me.callFail('systemFailure');
        }
    };

    me.doSuccess = function (data) {
        if (typeof(me.successCallback) === 'function') {
            me.successCallback(this, data);
        }
    };

    me.callFail = function(message){
        if (typeof(me.failCallback) === 'function') {
            me.failCallback(message);
        }
    };
};
@@ -118,37 +118,8 @@
 l;%0A%0A
-    me.failCallback = null;%0A%0A
     
@@ -164,85 +164,24 @@
 rd, 
-successCallback, failCallback) %7B%0A%0A        me.successCallback=successCallback;
+failCallback) %7B%0A
 %0A   
@@ -493,34 +493,99 @@
 ccess : 
-me.processResponse
+function(data)%7B%0A                me.processResponse(data,failCallback)%0A            %7D
 ,%0A      
@@ -609,27 +609,28 @@
 ction()%7B
-me.callFail
+failCallback
 ('system
@@ -703,34 +703,20 @@
 data
-) %7B%0A        if(!data.dataO
+,failCallbac
 k) %7B
@@ -728,110 +728,29 @@
     
-   
- 
 if
- 
 (!data
-.error) %7B%0A                me.doSystemFailure(data);%0A                return%0A            %7D%0A
+%5B'dataOk'%5D) %7B
 %0A   
@@ -782,14 +782,30 @@
 data
-.
+%5B'
 error
+'%5D,failCallback
 );%0A 
@@ -846,26 +846,43 @@
     
-me.doSuccess(data)
+window.location=data%5B'redirectUrl'%5D
 ;%0A  
@@ -927,363 +927,92 @@
 rror
-) %7B%0A        switch(error) %7B%0A            case 'missingNeeded':%0A                me.callFail('missing');%0A                break;%0A            case 'invalid':%0A                me.callFail('invalid');%0A                break;%0A            case 'noAuth':%0A                me.callFail('invalid');%0A                break;%0A            default:%0A                me.callFail(
+, failCallback) %7B%0A        if(error!='missing'&&error!='invalid')%7B%0A            error=
 'sys
@@ -1022,17 +1022,16 @@
 Failure'
-)
 ;%0A      
@@ -1042,306 +1042,32 @@
     
-%7D;%0A%0A    me.doSuccess = function (data) %7B%0A        if (typeof(me.successCallback) === 'function') %7B%0A            me.successCallback(this, data);%0A        %7D%0A    %7D;%0A%0A    me.callFail = function(message)%7B%0A        if (typeof(me.failCallback) === 'function') %7B%0A            me.failCallback(message);%0A        %7D
+    failCallback(error);
 %0A   

fix login redirection