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. // contains two cryptographic functions for both storing and comparing passwords.
package crypto package lea
import ( import (
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"

View File

@ -4,7 +4,6 @@ import (
"gopkg.in/mgo.v2/bson" "gopkg.in/mgo.v2/bson"
// "github.com/leanote/leanote/app/db" // "github.com/leanote/leanote/app/db"
"github.com/leanote/leanote/app/info" "github.com/leanote/leanote/app/info"
. "github.com/leanote/leanote/app/crypto"
// "github.com/revel/revel" // "github.com/revel/revel"
"strings" "strings"
. "github.com/leanote/leanote/app/lea" . "github.com/leanote/leanote/app/lea"
@ -26,12 +25,13 @@ func (this *AuthService) Login(emailOrUsername, pwd string) (info.User, error) {
passwd := userInfo.Pwd passwd := userInfo.Pwd
if len(passwd) == 32 && Md5(pwd) != passwd { if len(passwd) == 32 && Md5(pwd) != passwd {
return userInfo, errors.New("wrong username or password") return userInfo, errors.New("wrong username or password")
} else { }
if len(passwd) > 32 {
hex := []byte(passwd) hex := []byte(passwd)
if !CompareHash(hex, pwd) { if !CompareHash(hex, pwd) {
return userInfo, errors.New("wrong username or password") return userInfo, errors.New("wrong username or password")
} }
} }
return userInfo, nil return userInfo, nil
} }

View File

@ -4,7 +4,7 @@ import (
"gopkg.in/mgo.v2/bson" "gopkg.in/mgo.v2/bson"
"github.com/leanote/leanote/app/db" "github.com/leanote/leanote/app/db"
"github.com/leanote/leanote/app/info" "github.com/leanote/leanote/app/info"
. "github.com/leanote/leanote/app/crypto" . "github.com/leanote/leanote/app/lea"
) )
// 找回密码 // 找回密码