aboutsummaryrefslogtreecommitdiff
path: root/models/login_source.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2017-03-12 00:47:34 -0500
committerUnknwon <u@gogs.io>2017-03-12 00:47:34 -0500
commit05dbd3f7d78162bf06785faf0ea862fa2dc4f012 (patch)
tree2343371aff5f74df5ca48040357aa31ee37b68b5 /models/login_source.go
parentdee76e4189446d97040e8c715a811424bd91704c (diff)
refactoring: experimental with models/errors package
Diffstat (limited to 'models/login_source.go')
-rw-r--r--models/login_source.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/models/login_source.go b/models/login_source.go
index 8a30ad22..1191994d 100644
--- a/models/login_source.go
+++ b/models/login_source.go
@@ -7,7 +7,6 @@ package models
import (
"crypto/tls"
"encoding/json"
- "errors"
"fmt"
"net/smtp"
"net/textproto"
@@ -20,6 +19,7 @@ import (
"github.com/go-xorm/xorm"
log "gopkg.in/clog.v1"
+ "github.com/gogits/gogs/models/errors"
"github.com/gogits/gogs/modules/auth/ldap"
"github.com/gogits/gogs/modules/auth/pam"
)
@@ -394,7 +394,7 @@ func SMTPAuth(a smtp.Auth, cfg *SMTPConfig) error {
}
return nil
}
- return ErrUnsupportedLoginType
+ return errors.New("Unsupported SMTP authentication method")
}
// LoginViaSMTP queries if login/password is valid against the SMTP,
@@ -416,7 +416,7 @@ func LoginViaSMTP(user *User, login, password string, sourceID int64, cfg *SMTPC
} else if cfg.Auth == SMTP_LOGIN {
auth = &smtpLoginAuth{login, password}
} else {
- return nil, errors.New("Unsupported SMTP auth type")
+ return nil, errors.New("Unsupported SMTP authentication type")
}
if err := SMTPAuth(auth, cfg); err != nil {
@@ -489,7 +489,7 @@ func LoginViaPAM(user *User, login, password string, sourceID int64, cfg *PAMCon
func ExternalUserLogin(user *User, login, password string, source *LoginSource, autoRegister bool) (*User, error) {
if !source.IsActived {
- return nil, ErrLoginSourceNotActived
+ return nil, errors.LoginSourceNotActivated{source.ID}
}
switch source.Type {
@@ -501,7 +501,7 @@ func ExternalUserLogin(user *User, login, password string, source *LoginSource,
return LoginViaPAM(user, login, password, source.ID, source.Cfg.(*PAMConfig), autoRegister)
}
- return nil, ErrUnsupportedLoginType
+ return nil, errors.InvalidLoginSourceType{source.Type}
}
// UserSignIn validates user name and password.