Skip to content

Commit

Permalink
Move score from uint to float32
Browse files Browse the repository at this point in the history
  • Loading branch information
hazcod authored Apr 24, 2019
1 parent 6825d7b commit 3acbdbf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions recaptcha.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
// google recaptcha response
type recaptchaResponse struct {
Success bool `json:"success"`
Score uint `json:"score"`
Score float32 `json:"score"`
Action string `json:"action"`
ChallengeTS time.Time `json:"challenge_ts"`
Hostname string `json:"hostname"`
Expand Down Expand Up @@ -72,7 +72,7 @@ func (r *Recaptcha) requestVerify(remoteAddr net.IP, captchaResponse string) (re
}

// Check : check user IP, captcha subject (= page) and captcha response but return treshold
func (r *Recaptcha) Check(remoteip net.IP, action string, response string) (success bool, score uint, err error) {
func (r *Recaptcha) Check(remoteip net.IP, action string, response string) (success bool, score float32, err error) {
resp, err := r.requestVerify(remoteip, response)
// fetch/parsing failed
if err != nil {
Expand All @@ -94,7 +94,7 @@ func (r *Recaptcha) Check(remoteip net.IP, action string, response string) (succ
}

// Verify : check user IP, captcha subject (= page) and captcha response
func (r *Recaptcha) Verify(remoteip net.IP, action string, response string, minScore uint) (success bool, err error) {
func (r *Recaptcha) Verify(remoteip net.IP, action string, response string, minScore float32) (success bool, err error) {
success, score, err := r.Check(remoteip, action, response)

// return false if response failed
Expand Down

0 comments on commit 3acbdbf

Please sign in to comment.