Skip to content

Commit

Permalink
Check if keys exist in map. Fixes: #736
Browse files Browse the repository at this point in the history
  • Loading branch information
unicod3 committed May 20, 2019
1 parent ce78299 commit 473aaf1
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions cmd/config.go
Expand Up @@ -89,25 +89,24 @@ func getAuthentication(flags *pflag.FlagSet, defaults ...interface{}) (settings.
secret := mustGetString(flags, "recaptcha.secret")

if key == "" {
kmap := defaultAuther["recaptcha"].(map[string]interface{})
key = kmap["key"].(string)
if kmap, ok := defaultAuther["recaptcha"].(map[string]interface{}); ok {
key = kmap["key"].(string)
}
}

if secret == "" {
smap := defaultAuther["recaptcha"].(map[string]interface{})
secret = smap["secret"].(string)
}

if key == "" || secret == "" {
checkErr(nerrors.New("you must set the flag 'recaptcha.key' and 'recaptcha.secret' for method 'json'"))
if smap, ok := defaultAuther["recaptcha"].(map[string]interface{}); ok {
secret = smap["secret"].(string)
}
}

jsonAuth.ReCaptcha = &auth.ReCaptcha{
Host: host,
Key: key,
Secret: secret,
if key != "" && secret != "" {
jsonAuth.ReCaptcha = &auth.ReCaptcha{
Host: host,
Key: key,
Secret: secret,
}
}

auther = jsonAuth
}

Expand Down

0 comments on commit 473aaf1

Please sign in to comment.