Merge branch 'dev' of github.com:gogits/gogs into dev

This commit is contained in:
skyblue 2014-04-06 23:12:29 +08:00
commit 5e534bf2a5
24 changed files with 481 additions and 105 deletions

View file

@ -78,7 +78,7 @@ func init() {
type PublicKey struct {
Id int64
OwnerId int64 `xorm:"unique(s) index not null"`
Name string `xorm:"unique(s) not null"` //UNIQUE(s)
Name string `xorm:"unique(s) not null"`
Fingerprint string
Content string `xorm:"TEXT not null"`
Created time.Time `xorm:"created"`

View file

@ -367,6 +367,21 @@ func GetUserByName(name string) (*User, error) {
return user, nil
}
// GetUserByEmail returns the user object by given e-mail if exists.
func GetUserByEmail(email string) (*User, error) {
if len(email) == 0 {
return nil, ErrUserNotExist
}
user := &User{Email: strings.ToLower(email)}
has, err := orm.Get(user)
if err != nil {
return nil, err
} else if !has {
return nil, ErrUserNotExist
}
return user, nil
}
// LoginUserPlain validates user by raw user name and password.
func LoginUserPlain(name, passwd string) (*User, error) {
user := User{LowerName: strings.ToLower(name), Passwd: passwd}