You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mcaptcha.go 609B

1234567891011121314151617181920212223242526
  1. // Copyright 2022 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package mcaptcha
  4. import (
  5. "context"
  6. "fmt"
  7. "code.gitea.io/gitea/modules/setting"
  8. "codeberg.org/gusted/mcaptcha"
  9. )
  10. func Verify(ctx context.Context, token string) (bool, error) {
  11. valid, err := mcaptcha.Verify(ctx, &mcaptcha.VerifyOpts{
  12. InstanceURL: setting.Service.McaptchaURL,
  13. Sitekey: setting.Service.McaptchaSitekey,
  14. Secret: setting.Service.McaptchaSecret,
  15. Token: token,
  16. })
  17. if err != nil {
  18. return false, fmt.Errorf("wasn't able to verify mCaptcha: %w", err)
  19. }
  20. return valid, nil
  21. }