X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Fcore%2Fwebservice.rb;h=0ddbc2d5941288ac1945de36c56f43d8ffcfb006;hb=68bf927fa4642cf76d696e20e69353c8722707f0;hp=c3e61f49e2be43983d20b5e7c3004bcfda0bd3c8;hpb=c5ee1de18a464075f00b6f348d494302f751e5e5;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/core/webservice.rb b/lib/rbot/core/webservice.rb index c3e61f49..0ddbc2d5 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 @@ -216,7 +217,7 @@ class Bot tmpl = @templates[index] raise "Botmodule #{botmodule.name} tried to unmap #{tmpl.inspect} that was handled by #{tmpl.botmodule}" unless tmpl.botmodule == botmodule.name debug "Unmapping #{tmpl.inspect}" - @templates[handle] = nil + @templates[index] = nil @templates.clear unless @templates.compact.size > 0 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'