two_factor.go 628 B

123456789101112131415161718192021222324252627282930
  1. package errors
  2. import "fmt"
  3. type TwoFactorNotFound struct {
  4. UserID int64
  5. }
  6. func IsTwoFactorNotFound(err error) bool {
  7. _, ok := err.(TwoFactorNotFound)
  8. return ok
  9. }
  10. func (err TwoFactorNotFound) Error() string {
  11. return fmt.Sprintf("two-factor authentication does not found [user_id: %d]", err.UserID)
  12. }
  13. type TwoFactorRecoveryCodeNotFound struct {
  14. Code string
  15. }
  16. func IsTwoFactorRecoveryCodeNotFound(err error) bool {
  17. _, ok := err.(TwoFactorRecoveryCodeNotFound)
  18. return ok
  19. }
  20. func (err TwoFactorRecoveryCodeNotFound) Error() string {
  21. return fmt.Sprintf("two-factor recovery code does not found [code: %s]", err.Code)
  22. }