0ebb45cfe7
Found using `find . -type f -name '*.go' -print -exec vim {} -c ':%s/fmt\.Errorf(\(.*\)%v\(.*\)err/fmt.Errorf(\1%w\2err/g' -c ':wq' \;` Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
28 lines
681 B
Go
28 lines
681 B
Go
// Copyright 2022 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 mcaptcha
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
"codeberg.org/gusted/mcaptcha"
|
|
)
|
|
|
|
func Verify(ctx context.Context, token string) (bool, error) {
|
|
valid, err := mcaptcha.Verify(ctx, &mcaptcha.VerifyOpts{
|
|
InstanceURL: setting.Service.McaptchaURL,
|
|
Sitekey: setting.Service.McaptchaSitekey,
|
|
Secret: setting.Service.McaptchaSecret,
|
|
Token: token,
|
|
})
|
|
if err != nil {
|
|
return false, fmt.Errorf("wasn't able to verify mCaptcha: %w", err)
|
|
}
|
|
return valid, nil
|
|
}
|