alternative ReCaptcha, close #366

Former-commit-id: c8c9baff75891868283bd353c83a19d38e6bc0e9 [formerly 88aeffc35a402c44c9c92a534c8cd271124826a7] [formerly 39cfd0e090894509e913100aa2f9b325ad6e5b68 [formerly 6e1c6a4a8c]]
Former-commit-id: a49c1046af3ba28c469e93e7d88013f5a6b1d062 [formerly 07c801b64ed03b187bb1dd9bbfb502b92572af44]
Former-commit-id: aa69ed3d4d78f8942b8b2c924c73c8e4c4965520
This commit is contained in:
Equim
2018-02-28 01:12:54 +08:00
committed by Henrique Dias
parent a2fcb8b3b0
commit 0cff87be24
5 changed files with 40 additions and 11 deletions

View File

@@ -49,6 +49,7 @@ func Parse(c *caddy.Controller, plugin string) ([]*filebrowser.FileBrowser, erro
scope := "."
database := ""
noAuth := false
alterRecaptcha := false
reCaptchaKey := ""
reCaptchaSecret := ""
@@ -158,6 +159,16 @@ func Parse(c *caddy.Controller, plugin string) ([]*filebrowser.FileBrowser, erro
if u.ViewMode != filebrowser.MosaicViewMode && u.ViewMode != filebrowser.ListViewMode {
return nil, c.ArgErr()
}
case "alternative_recaptcha":
if !c.NextArg() {
alterRecaptcha = true
continue
}
alterRecaptcha, err = strconv.ParseBool(c.Val())
if err != nil {
return nil, err
}
case "recaptcha_key":
if !c.NextArg() {
return nil, c.ArgErr()
@@ -227,10 +238,16 @@ func Parse(c *caddy.Controller, plugin string) ([]*filebrowser.FileBrowser, erro
return nil, err
}
recaptchaHost := "https://www.google.com"
if alterRecaptcha {
recaptchaHost = "https://recaptcha.net"
}
m := &filebrowser.FileBrowser{
NoAuth: noAuth,
BaseURL: "",
PrefixURL: "",
ReCaptchaHost: recaptchaHost,
ReCaptchaKey: reCaptchaKey,
ReCaptchaSecret: reCaptchaSecret,
DefaultUser: u,