Results 1 to 7 of 7

Thread: Redirection for Login Page

  1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    149
    Answers
    2
    Vote Rating
    1
      0  

    Default Answered: Redirection for Login Page

    Hello folks

    I have developed an extjs email application and added a spring security module to it for authentication.
    Now everything works fine i.e User logs in->performs operation->logs out.
    But after log out I have redirected the user back to the login page using.

    Code:
    <security:logout logout-success-url="/login.jsp"/>
    in my spring security.xml file.
    The redirect works but,if I try to log in again I get an error in firebug
    Code:
    Ext.util.JSON is undefined
    
    
    [IMG]chrome://firebug/content/blank.gif[/IMG] obj = Ext.util.JSON.decode(action.response.responseText);
    under the Response tab in firebug
    Code:
    { success: false, errors: { reason: 'Login failed. Try again.' }}
    I have this in my login.js
    Code:
     buttons:[{
                text:'Login',
                formBind: true,
                // Function that fires when user clicks the button
                handler:function(){
                login.getForm().submit({
    
                    method:'POST', 
                    success:function(){
                    Ext.Msg.alert('Status', 'Login Successful!', function(btn, text){
                        if (btn == 'ok'){
                              window.location = 'index.action';
                        }
                    });
    
                },
    
                   failure:function(form, action){
                    if(action.failureType == 'server'){
                        obj = Ext.util.JSON.decode(action.response.responseText);
    
                        Ext.Msg.alert('Login Failed!', obj.errors.reason);
                    }else{
                        Ext.Msg.alert('Warning!', 'Authentication server is unreachable : ' + action.response.responseText);
                        //window.location='loginFailure.html'+action.response.responseText;    
                    }
                    login.getForm().reset();
                } 
    
                });
            }
            }]
        });
    Please correct me where is the mistake.

    Thanks

  2. If I remember correctly, I think a Form Panel already decodes the response for you as JSON, so you can go directly after action.errors.reason without having to decode.

    If you want to see exactly what's in the action object, you can run it through my favorite debugging function, to dump all of its attributes/values:

    Code:
     dumpObject: function(obj) {
        console.log('===== >>> START Object enumeration =============================');
        for (props in obj) {
          console.log('property: ' + props);
          console.log('value: ' + obj[props] );
          console.log('\n\n');
        }
        console.log('===== <<< END Object enumeration ===============================');
      }
    
    dumpObject(action);
    You can also run it against specific child properties of the action object:

    Code:
    dumpObject(action.response);

  3. #2
    Sencha User
    Join Date
    May 2011
    Location
    Ukraine, Rivne
    Posts
    250
    Answers
    44
    Vote Rating
    46
      0  

    Default

    Maybe ext lib not loaded? Look in firebug js tab.

  4. #3
    Sencha User friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Answers
    106
    Vote Rating
    27
      0  

    Default

    If I remember correctly, I think a Form Panel already decodes the response for you as JSON, so you can go directly after action.errors.reason without having to decode.

    If you want to see exactly what's in the action object, you can run it through my favorite debugging function, to dump all of its attributes/values:

    Code:
     dumpObject: function(obj) {
        console.log('===== >>> START Object enumeration =============================');
        for (props in obj) {
          console.log('property: ' + props);
          console.log('value: ' + obj[props] );
          console.log('\n\n');
        }
        console.log('===== <<< END Object enumeration ===============================');
      }
    
    dumpObject(action);
    You can also run it against specific child properties of the action object:

    Code:
    dumpObject(action.response);

  5. #4
    Sencha User
    Join Date
    May 2011
    Location
    Ukraine, Rivne
    Posts
    250
    Answers
    44
    Vote Rating
    46
      0  

    Default

    My previous post wrong, here error:
    Code:
    obj = Ext.util.JSON.decode(action.response.responseText); // Ext.util dont have JSON class // use obj = Ext.JSON.decode(action.response.responseText);
    http://docs.sencha.com/ext-js/4-1/#!...-method-decode

  6. #5
    Sencha User
    Join Date
    Nov 2011
    Posts
    149
    Answers
    2
    Vote Rating
    1
      0  

    Default

    @redraid No there is no such fle missing.I did not find it even when i searched the framework folder.What is th exact file name?can you please tell.
    Will try your solution and debug to fix it.


    @friend:Good to see you after long time.
    I will try it and let you know.

    Thanks to both.

  7. #6
    Sencha User friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Answers
    106
    Vote Rating
    27
      0  

    Default

    @sachintaware: Congrats on the making the leap to Spring Framework/MVC/Security. It looks like you're making good progress!

    As for JSON encoding/decoding, there are two wrapped convenience methods for doing this:

    Ext.decode() and Ext.encode().

  8. #7
    Sencha User
    Join Date
    Nov 2011
    Posts
    149
    Answers
    2
    Vote Rating
    1
      0  

    Default

    @friend: Yes,made some progress,but was not possible without some great support by the forum members like you,otherwise I would have given up long back.

    But I get stuck more often then not.
    I am trying to debug this thread issue and I have another one posted earlier and not resolved yet.

    @friend @redraid here it is.I get this in Mozilla but not in Chrome(not tested on other browsers though).
    Here is the thread: http://www.sencha.com/forum/showthre...gmvc-and-extjs

    Please go through and post your comments/views.I have to make it live ASAP.

    Thanks for your continues support.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •