From a617d52374e937db0edacfba2a26bdd14a05538e Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 6 Apr 2017 00:14:30 -0400 Subject: 2fa: initial support (#945) --- models/errors/two_factor.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 models/errors/two_factor.go (limited to 'models/errors') diff --git a/models/errors/two_factor.go b/models/errors/two_factor.go new file mode 100644 index 00000000..02cdcf5c --- /dev/null +++ b/models/errors/two_factor.go @@ -0,0 +1,33 @@ +// Copyright 2017 The Gogs 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 errors + +import "fmt" + +type TwoFactorNotFound struct { + UserID int64 +} + +func IsTwoFactorNotFound(err error) bool { + _, ok := err.(TwoFactorNotFound) + return ok +} + +func (err TwoFactorNotFound) Error() string { + return fmt.Sprintf("two-factor authentication does not found [user_id: %d]", err.UserID) +} + +type TwoFactorRecoveryCodeNotFound struct { + Code string +} + +func IsTwoFactorRecoveryCodeNotFound(err error) bool { + _, ok := err.(TwoFactorRecoveryCodeNotFound) + return ok +} + +func (err TwoFactorRecoveryCodeNotFound) Error() string { + return fmt.Sprintf("two-factor recovery code does not found [code: %s]", err.Code) +} -- cgit v1.2.3