1
0
Fork 0
forked from forgejo/forgejo

Change /user/profile URL to /user/:username

This commit is contained in:
Unknown 2014-03-07 17:08:21 -05:00
parent ba5c7ea771
commit a2a59f8ad1
11 changed files with 96 additions and 83 deletions

View file

@ -190,6 +190,23 @@ func GetUserById(id int64) (*User, error) {
return user, nil
}
func GetUserByName(name string) (*User, error) {
if len(name) == 0 {
return nil, ErrUserNotExist
}
user := &User{
LowerName: strings.ToLower(name),
}
has, err := orm.Get(user)
if err != nil {
return nil, err
}
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}