Merge pull request #25 from crowdsecurity/fix_error
improve configuration mgmt code
This commit is contained in:
commit
ab667b6779
3 changed files with 9 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue