two_factor.go 862 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2015 The Gogs Authors. All rights reserved.
  2. // Copyright 2018 Gitote. All rights reserved.
  3. //
  4. // This source code is licensed under the MIT license found in the
  5. // LICENSE file in the root directory of this source tree.
  6. package errors
  7. import "fmt"
  8. type TwoFactorNotFound struct {
  9. UserID int64
  10. }
  11. func IsTwoFactorNotFound(err error) bool {
  12. _, ok := err.(TwoFactorNotFound)
  13. return ok
  14. }
  15. func (err TwoFactorNotFound) Error() string {
  16. return fmt.Sprintf("two-factor authentication does not found [user_id: %d]", err.UserID)
  17. }
  18. type TwoFactorRecoveryCodeNotFound struct {
  19. Code string
  20. }
  21. func IsTwoFactorRecoveryCodeNotFound(err error) bool {
  22. _, ok := err.(TwoFactorRecoveryCodeNotFound)
  23. return ok
  24. }
  25. func (err TwoFactorRecoveryCodeNotFound) Error() string {
  26. return fmt.Sprintf("two-factor recovery code does not found [code: %s]", err.Code)
  27. }