]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
web service: fix basic auth handler
authorMatthias H <apoc@sixserv.org>
Mon, 12 Jan 2015 11:02:21 +0000 (12:02 +0100)
committerMatthias H <apoc@sixserv.org>
Mon, 12 Jan 2015 11:02:21 +0000 (12:02 +0100)
lib/rbot/core/webservice.rb

index c3e61f49e2be43983d20b5e7c3004bcfda0bd3c8..c823594ad437fecc8473e29fd8b35118b625f984 100644 (file)
@@ -73,8 +73,9 @@ class Bot
             if botuser and botuser.password == password
               @source = botuser
               true
+            else
+              false
             end
-            false
           else
             true # no need to request auth at this point
           end
@@ -351,6 +352,11 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
     begin
       m = WebMessage.new(@bot, req, res)
       @bot.web_dispatcher.handle m
+    rescue WEBrick::HTTPStatus::Unauthorized
+      res.status = 401
+      res['Content-Type'] = 'text/plain'
+      res.body = 'Authentication Required!'
+      error 'authentication error (wrong password)'
     rescue
       res.status = 500
       res['Content-Type'] = 'text/plain'