diff options
author | Andrew <write@imaginarycode.com> | 2017-01-15 21:14:29 -0500 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-01-16 10:14:29 +0800 |
commit | 6dd096b7f08799ff27d9e34356fb1163ca10f388 (patch) | |
tree | e5823a27df5def081c9c39f5fac1424a81875f6d /models/error.go | |
parent | 64375d875b4d46a6081026290da8efd82c84b25f (diff) | |
download | gitea-6dd096b7f08799ff27d9e34356fb1163ca10f388.tar.gz gitea-6dd096b7f08799ff27d9e34356fb1163ca10f388.zip |
Two factor authentication support (#630)
* Initial commit for 2FA support
Signed-off-by: Andrew <write@imaginarycode.com>
* Add vendored files
* Add missing depends
* A few clean ups
* Added improvements, proper encryption
* Better encryption key
* Simplify "key" generation
* Make 2FA enrollment page more robust
* Fix typo
* Rename twofa/2FA to TwoFactor
* UNIQUE INDEX -> UNIQUE
Diffstat (limited to 'models/error.go')
-rw-r--r-- | models/error.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/models/error.go b/models/error.go index edbb6003e9..e0d33df6dc 100644 --- a/models/error.go +++ b/models/error.go @@ -787,6 +787,25 @@ func (err ErrTeamAlreadyExist) Error() string { return fmt.Sprintf("team already exists [org_id: %d, name: %s]", err.OrgID, err.Name) } +// +// Two-factor authentication +// + +// ErrTwoFactorNotEnrolled indicates that a user is not enrolled in two-factor authentication. +type ErrTwoFactorNotEnrolled struct { + UID int64 +} + +// IsErrTwoFactorNotEnrolled checks if an error is a ErrTwoFactorNotEnrolled. +func IsErrTwoFactorNotEnrolled(err error) bool { + _, ok := err.(ErrTwoFactorNotEnrolled) + return ok +} + +func (err ErrTwoFactorNotEnrolled) Error() string { + return fmt.Sprintf("user not enrolled in 2FA [uid: %d]", err.UID) +} + // ____ ___ .__ .___ // | | \______ | | _________ __| _/ // | | /\____ \| | / _ \__ \ / __ | |