Merge pull request #25 from crowdsecurity/fix_error

improve configuration mgmt code
This commit is contained in:
he2ss 2022-02-08 18:05:55 +01:00 committed by GitHub
commit ab667b6779
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View file

@ -9,6 +9,9 @@ M.ret_code = ngx.HTTP_FORBIDDEN
function M.new(template_path, redirect_location, ret_code)
if template_path == nil then
return "BAN_TEMPLATE_PATH variable is empty, will ban without template"
end
if utils.file_exist(template_path) == false then
return "ban template file doesn't exist, will ban without template"
else

View file

@ -45,6 +45,9 @@ function M.New(siteKey, secretKey, TemplateFilePath)
M.SecretKey = secretKey
if TemplateFilePath == nil then
return "CAPTCHA_TEMPLATE_PATH variable is empty, will ban without template"
end
if utils.file_exist(TemplateFilePath) == false then
return "captcha template file doesn't exist, can't use recaptcha"
end

View file

@ -25,6 +25,9 @@ function M.read_file(path)
end
function M.file_exist(path)
if path == nil then
return nil
end
local f = io.open(path, "r")
if f ~= nil then
io.close(f)