mv crypto to lea
This commit is contained in:
@ -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"
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 找回密码
|
// 找回密码
|
||||||
|
Reference in New Issue
Block a user