Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b86922
commit 04472e2
Showing
8 changed files
with
98 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package recaptcha | ||
|
||
import ( | ||
"github.com/haisum/recaptcha" | ||
"net/http" | ||
) | ||
|
||
var ( | ||
recap RecaptchaInfo | ||
) | ||
|
||
// RecaptchaInfo has the details for the Google reCAPTCHA | ||
type RecaptchaInfo struct { | ||
Enabled bool | ||
Secret string | ||
SiteKey string | ||
} | ||
|
||
// Configure adds the settings for Google reCAPTCHA | ||
func Configure(c RecaptchaInfo) { | ||
recap = c | ||
} | ||
|
||
// ReadConfig returns the settings for Google reCAPTCHA | ||
func ReadConfig() RecaptchaInfo { | ||
return recap | ||
} | ||
|
||
// Verified returns whether the Google reCAPTCHA was verified or not | ||
func Verified(r *http.Request) bool { | ||
if !recap.Enabled { | ||
return true | ||
} | ||
|
||
// Check the reCaptcha | ||
re := recaptcha.R{ | ||
Secret: recap.Secret, | ||
} | ||
return re.Verify(*r) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters