summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMatthias H <apoc@sixserv.org>2015-01-12 12:02:21 +0100
committerMatthias H <apoc@sixserv.org>2015-01-12 12:02:21 +0100
commit592c800425410f63b1a6ebf467d32273ccd377b4 (patch)
tree4d8bc0f487bc348ebf523a7ae1ed9b38e2159a9f /lib
parentc5ee1de18a464075f00b6f348d494302f751e5e5 (diff)
web service: fix basic auth handler
Diffstat (limited to 'lib')
-rw-r--r--lib/rbot/core/webservice.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/rbot/core/webservice.rb b/lib/rbot/core/webservice.rb
index c3e61f49..c823594a 100644
--- a/lib/rbot/core/webservice.rb
+++ b/lib/rbot/core/webservice.rb
@@ -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'