From f2ecfdc96a338815ffb2be898b3114031f0da48c Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 12 Apr 2018 09:55:58 -0400 Subject: auth: support authentication source config file (#3142) --- models/errors/login_source.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'models/errors/login_source.go') diff --git a/models/errors/login_source.go b/models/errors/login_source.go index db0cd1f9..dd18664e 100644 --- a/models/errors/login_source.go +++ b/models/errors/login_source.go @@ -6,6 +6,19 @@ package errors import "fmt" +type LoginSourceNotExist struct { + ID int64 +} + +func IsLoginSourceNotExist(err error) bool { + _, ok := err.(LoginSourceNotExist) + return ok +} + +func (err LoginSourceNotExist) Error() string { + return fmt.Sprintf("login source does not exist [id: %d]", err.ID) +} + type LoginSourceNotActivated struct { SourceID int64 } @@ -31,3 +44,17 @@ func IsInvalidLoginSourceType(err error) bool { func (err InvalidLoginSourceType) Error() string { return fmt.Sprintf("invalid login source type [type: %v]", err.Type) } + +type LoginSourceMismatch struct { + Expect int64 + Actual int64 +} + +func IsLoginSourceMismatch(err error) bool { + _, ok := err.(LoginSourceMismatch) + return ok +} + +func (err LoginSourceMismatch) Error() string { + return fmt.Sprintf("login source mismatch [expect: %d, actual: %d]", err.Expect, err.Actual) +} -- cgit v1.2.3