snapshot of https://github.com/go-gitea/gitea.git (main, 2026-09-15; blobs > 131072B omitted)
Some checks failed
cache-seeder / prune (push) Has been skipped
cache-seeder / frontend (push) Failing after 3s
cache-seeder / python (push) Failing after 3s
cache-seeder / gobuild (push) Failing after 4s
cache-seeder / lint (bindata, lint-backend) (push) Failing after 3s
giteabot backport / giteabot (push) Has been skipped
giteabot / giteabot (push) Has been skipped
cache-prune / prune (push) Has been skipped
release-nightly-snapcraft / build-and-publish (ubuntu-24.04) (push) Has been cancelled
release-nightly-snapcraft / build-and-publish (ubuntu-24.04-arm) (push) Has been cancelled
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-renovate / cron-renovate (push) Has been skipped
Some checks failed
cache-seeder / prune (push) Has been skipped
cache-seeder / frontend (push) Failing after 3s
cache-seeder / python (push) Failing after 3s
cache-seeder / gobuild (push) Failing after 4s
cache-seeder / lint (bindata, lint-backend) (push) Failing after 3s
giteabot backport / giteabot (push) Has been skipped
giteabot / giteabot (push) Has been skipped
cache-prune / prune (push) Has been skipped
release-nightly-snapcraft / build-and-publish (ubuntu-24.04) (push) Has been cancelled
release-nightly-snapcraft / build-and-publish (ubuntu-24.04-arm) (push) Has been cancelled
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-renovate / cron-renovate (push) Has been skipped
This commit is contained in:
47
modules/hcaptcha/error.go
Normal file
47
modules/hcaptcha/error.go
Normal file
@@ -0,0 +1,47 @@
|
||||
// Copyright 2023 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package hcaptcha
|
||||
|
||||
const (
|
||||
ErrMissingInputSecret ErrorCode = "missing-input-secret"
|
||||
ErrInvalidInputSecret ErrorCode = "invalid-input-secret"
|
||||
ErrMissingInputResponse ErrorCode = "missing-input-response"
|
||||
ErrInvalidInputResponse ErrorCode = "invalid-input-response"
|
||||
ErrBadRequest ErrorCode = "bad-request"
|
||||
ErrInvalidOrAlreadySeenResponse ErrorCode = "invalid-or-already-seen-response"
|
||||
ErrNotUsingDummyPasscode ErrorCode = "not-using-dummy-passcode"
|
||||
ErrSitekeySecretMismatch ErrorCode = "sitekey-secret-mismatch"
|
||||
)
|
||||
|
||||
// ErrorCode is any possible error from hCaptcha
|
||||
type ErrorCode string
|
||||
|
||||
// String fulfills the Stringer interface
|
||||
func (err ErrorCode) String() string {
|
||||
switch err {
|
||||
case ErrMissingInputSecret:
|
||||
return "Your secret key is missing."
|
||||
case ErrInvalidInputSecret:
|
||||
return "Your secret key is invalid or malformed."
|
||||
case ErrMissingInputResponse:
|
||||
return "The response parameter (verification token) is missing."
|
||||
case ErrInvalidInputResponse:
|
||||
return "The response parameter (verification token) is invalid or malformed."
|
||||
case ErrBadRequest:
|
||||
return "The request is invalid or malformed."
|
||||
case ErrInvalidOrAlreadySeenResponse:
|
||||
return "The response parameter has already been checked, or has another issue."
|
||||
case ErrNotUsingDummyPasscode:
|
||||
return "You have used a testing sitekey but have not used its matching secret."
|
||||
case ErrSitekeySecretMismatch:
|
||||
return "The sitekey is not registered with the provided secret."
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
// Error fulfills the error interface
|
||||
func (err ErrorCode) Error() string {
|
||||
return err.String()
|
||||
}
|
||||
Reference in New Issue
Block a user