Add reset password, fix #58

This commit is contained in:
Unknown 2014-04-05 12:32:34 -04:00
parent 3ebc9b991a
commit b7c3b0cc73
10 changed files with 214 additions and 29 deletions

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}