@@ -489,13 +489,23 @@ def inner_main(self):
489489 self .additional_headers ['Location' ] = str (url )
490490 self .response_code = 302
491491 self .write_html ('Redirecting to <a href="%s">%s</a>' % (url , url ))
492+ except LoginError , message :
493+ # The user tried to log in, but did not provide a valid
494+ # username and password. If we support HTTP
495+ # authorization, send back a response that will cause the
496+ # browser to prompt the user again.
497+ if self .instance .config .WEB_HTTP_AUTH :
498+ self .response_code = httplib .UNAUTHORIZED
499+ realm = self .instance .config .TRACKER_NAME
500+ self .setHeader ("WWW-Authenticate" ,
501+ "Basic realm=\" %s\" " % realm )
502+ else :
503+ self .response_code = httplib .FORBIDDEN
504+ self .renderFrontPage (message )
492505 except Unauthorised , message :
493506 # users may always see the front page
494507 self .response_code = 403
495- self .classname = self .nodeid = None
496- self .template = ''
497- self .error_message .append (message )
498- self .write_html (self .renderContext ())
508+ self .renderFrontPage (message )
499509 except NotModified :
500510 # send the 304 response
501511 self .response_code = 304
@@ -676,7 +686,7 @@ def determine_user(self):
676686 login .verifyLogin (username , password )
677687 except LoginError , err :
678688 self .make_user_anonymous ()
679- raise Unauthorised , err
689+ raise
680690 user = username
681691
682692 # if user was not set by http authorization, try session lookup
@@ -972,6 +982,14 @@ def send_html_to_admin(self, subject, content):
972982 encode_quopri (message )
973983 self .mailer .smtp_send (to , str (message ))
974984
985+ def renderFrontPage (self , message ):
986+ """Return the front page of the tracker."""
987+
988+ self .classname = self .nodeid = None
989+ self .template = ''
990+ self .error_message .append (message )
991+ self .write_html (self .renderContext ())
992+
975993 def renderContext (self ):
976994 """ Return a PageTemplate for the named page
977995 """
0 commit comments