Results 1 to 7 of 7

Thread: How can I prevent the 401 Authentication dialog for Ajax requests with invalid creds?

  1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    16
    Answers
    1
    Vote Rating
    1
      0  

    Default Unanswered: How can I prevent the 401 Authentication dialog for Ajax requests with invalid creds?

    Hello,

    I've an application that authenticates via HTTP (as described in my previous post). I've a problem when the user enters invalid authorization data, the client calls the function to get the settings on the server. If this function success without errors, the user is logged in. But if the authentication fails, the server throws a 401 missing authorization error. The browser will handle this error. So the default authorization dialog pops up. Can I prevent this default authorization dialog?

  2. #2
    Sencha User
    Join Date
    Feb 2012
    Posts
    16
    Answers
    1
    Vote Rating
    1
      0  

    Default

    Does really nobody know the answer?

  3. #3
    Sencha Premium Member
    Join Date
    Jun 2007
    Location
    Ostrava, Czech Republic
    Posts
    43
    Vote Rating
    3
      0  

    Default 401 handler in AJAX call

    Hi,

    try to handle exceptions. I use following construction in Sencha Touch. In Ext JS 3 I used similar codein combination with plugin to stock call and recall them after succesful login
    PHP Code:
    Ext.Ajax.on('requestexception', function (connresponseoptions) {

                switch (
    response.status) {
                    case 
    :
                        
    Ext.Msg.alert(Loading error!', 'No connection.');
                        break;
                    case 401 :
                        Ext.Msg.alert('
    Authentication failed!', 'Fill your credentials.');
                        break;
                    default :
                        Ext.Msg.alert('
    Uups!', 'Error.');
                }
            }); 
    Btw. There could be problem with options.records length when loading store and receiving 401.

  4. #4
    Sencha User
    Join Date
    Feb 2012
    Posts
    16
    Answers
    1
    Vote Rating
    1
      0  

    Default

    Hello,

    yes this error handling works after the browser authentication dialog is shown. The script execution is stopped until the user clicks "Cancel" in this dialog. After that the error handler will be executed. I'm looking for a solution that prevents the authentication dialog of the browser.

  5. #5
    Sencha Premium Member
    Join Date
    Jan 2012
    Posts
    15
    Vote Rating
    1
      0  

    Default

    Quote Originally Posted by Tequiol View Post
    Hello,

    yes this error handling works after the browser authentication dialog is shown. The script execution is stopped until the user clicks "Cancel" in this dialog. After that the error handler will be executed. I'm looking for a solution that prevents the authentication dialog of the browser.
    Tequiol, did you find a solution to this?

  6. #6
    Sencha User
    Join Date
    Feb 2012
    Posts
    16
    Answers
    1
    Vote Rating
    1
      0  

    Default

    No, I never found a solution for this.

  7. #7
    Sencha User
    Join Date
    Sep 2011
    Posts
    574
    Answers
    59
    Vote Rating
    74
      0  

    Default

    Can't your server return just 403 for AJAX requests instead of 401?
    Then you will be able to perform proper error handling.

Posting Permissions

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