mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-25 11:22:16 +00:00
Allow Recaptcha service url to be configured (#6820)
This commit is contained in:
parent
159294f799
commit
ade88a877d
8 changed files with 20 additions and 5 deletions
|
@ -13,6 +13,7 @@ import (
|
|||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
)
|
||||
|
||||
// Response is the structure of JSON returned from API
|
||||
|
@ -23,11 +24,11 @@ type Response struct {
|
|||
ErrorCodes []string `json:"error-codes"`
|
||||
}
|
||||
|
||||
const apiURL = "https://www.google.com/recaptcha/api/siteverify"
|
||||
const apiURL = "/api/siteverify"
|
||||
|
||||
// Verify calls Google Recaptcha API to verify token
|
||||
func Verify(response string) (bool, error) {
|
||||
resp, err := http.PostForm(apiURL,
|
||||
resp, err := http.PostForm(util.URLJoin(setting.Service.RecaptchaURL, apiURL),
|
||||
url.Values{"secret": {setting.Service.RecaptchaSecret}, "response": {response}})
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("Failed to send CAPTCHA response: %s", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue