diff --git a/app/crypto/crypto.go b/app/lea/crypto.go similarity index 84% rename from app/crypto/crypto.go rename to app/lea/crypto.go index 2c0d526..6ff8dc3 100644 --- a/app/crypto/crypto.go +++ b/app/lea/crypto.go @@ -1,5 +1,5 @@ -// Package crypto contains two cryptographic functions for both storing and comparing passwords. -package crypto +// contains two cryptographic functions for both storing and comparing passwords. +package lea import ( "golang.org/x/crypto/bcrypt" diff --git a/app/service/AuthService.go b/app/service/AuthService.go index 03f735c..c12d5f0 100644 --- a/app/service/AuthService.go +++ b/app/service/AuthService.go @@ -4,7 +4,6 @@ import ( "gopkg.in/mgo.v2/bson" // "github.com/leanote/leanote/app/db" "github.com/leanote/leanote/app/info" - . "github.com/leanote/leanote/app/crypto" // "github.com/revel/revel" "strings" . "github.com/leanote/leanote/app/lea" @@ -26,12 +25,13 @@ func (this *AuthService) Login(emailOrUsername, pwd string) (info.User, error) { passwd := userInfo.Pwd if len(passwd) == 32 && Md5(pwd) != passwd { return userInfo, errors.New("wrong username or password") - } else { + } + if len(passwd) > 32 { hex := []byte(passwd) if !CompareHash(hex, pwd) { return userInfo, errors.New("wrong username or password") - } - } + } + } return userInfo, nil } diff --git a/app/service/PwdService.go b/app/service/PwdService.go index 2c72c69..55e31c3 100644 --- a/app/service/PwdService.go +++ b/app/service/PwdService.go @@ -4,7 +4,7 @@ import ( "gopkg.in/mgo.v2/bson" "github.com/leanote/leanote/app/db" "github.com/leanote/leanote/app/info" - . "github.com/leanote/leanote/app/crypto" + . "github.com/leanote/leanote/app/lea" ) // 找回密码