-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
hCaptcha Support #12594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hCaptcha Support #12594
Changes from 6 commits
85e49dd
39bb157
25f21ff
8f50b3c
b36fa3e
8b9254f
2a1877b
46f7592
41c0ad4
7a52ab7
1fb2a2e
715c8f0
8ed5d8e
8b3e095
d60cdf7
b1ad889
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2020 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package hcaptcha | ||
|
||
import ( | ||
"code.gitea.io/gitea/modules/setting" | ||
|
||
"go.jolheiser.com/hcaptcha" | ||
) | ||
|
||
// Verify calls hCaptcha API to verify token | ||
func Verify(response string) (bool, error) { | ||
client, err := hcaptcha.New(setting.Service.RecaptchaSecret) | ||
jolheiser marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if err != nil { | ||
return false, err | ||
} | ||
|
||
resp, err := client.Verify(response, hcaptcha.PostOptions{ | ||
Sitekey: setting.Service.RecaptchaSitekey, | ||
}) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
return resp.Success, resp.ErrorCodes[0] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ const ( | |
const ( | ||
ImageCaptcha = "image" | ||
ReCaptcha = "recaptcha" | ||
HCaptcha = "hcaptcha" | ||
) | ||
|
||
// settings | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.