mv crypto to lea

This commit is contained in:
duoyun
2015-09-07 00:29:02 +08:00
parent bbaf71481c
commit 1604474d6e
3 changed files with 7 additions and 7 deletions

View File

@ -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"

View File

@ -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,7 +25,8 @@ 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")

View File

@ -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"
)
// 找回密码