javascript - How can I suppress the browser's authentication dialog? -


my web application has login page submits authentication credentials via ajax call. if user enters correct username , password, fine, if not, following happens:

  1. the web server determines although request included well-formed authorization header, credentials in header not authenticate.
  2. the web server returns 401 status code , includes 1 or more www-authenticate headers listing supported authentication types.
  3. the browser detects response call on xmlhttprequest object 401 , response includes www-authenticate headers. pops authentication dialog asking, again, username , password.

this fine until step 3. don't want dialog pop up, want want handle 401 response in ajax callback function. (for example, displaying error message on login page.) want user re-enter username , password, of course, want them see friendly, reassuring login form, not browser's ugly, default authentication dialog.

incidentally, have no control on server, having return custom status code (i.e., other 401) not option.

is there way can suppress authentication dialog? in particular, can suppress authentication required dialog in firefox 2 or later? there way suppress connect [host] dialog in ie 6 , later?


edit
additional information author (sept. 18):
should add real problem browser's authentication dialog popping give insufficient information user.

the user has entered username , password via form on login page, believes has typed them both correctly, , has clicked submit button or hit enter. expectation taken next page or perhaps told has entered information incorrectly , should try again. however, instead presented unexpected dialog box.

the dialog makes no acknowledgment of fact did enter username , password. not state there problem , should try again. instead, dialog box presents user cryptic information "the site says: '[realm]'." [realm] short realm name programmer love.

web broswer designers take note: no 1 ask how suppress authentication dialog if dialog more user-friendly. entire reason doing login form our product management team rightly considers browsers' authentication dialogs awful.

i don't think possible -- if use browser's http client implementation, pop dialog. 2 hacks come mind:

  1. maybe flash handles differently (i haven't tried yet), having flash movie make request might help.

  2. you can set 'proxie' service you're accessing on own server, , have modify authentication headers bit, browser doesn't recognise them.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -