diff options
author | Unknown <joe2010xtmf@163.com> | 2014-06-05 22:07:35 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-06-05 22:07:35 -0400 |
commit | 4f2f3c285717eff7a2f4ae2b79fbb0809e786dc8 (patch) | |
tree | 09e78d81573632b8638347c87d4f93d2f1c63f1b /models | |
parent | 11f9d738e8a1bce4c35bc5e1c37f5a7d1bcded5c (diff) | |
download | gitea-4f2f3c285717eff7a2f4ae2b79fbb0809e786dc8.tar.gz gitea-4f2f3c285717eff7a2f4ae2b79fbb0809e786dc8.zip |
Code convention
Diffstat (limited to 'models')
-rw-r--r-- | models/login.go | 4 | ||||
-rw-r--r-- | models/user.go | 27 |
2 files changed, 15 insertions, 16 deletions
diff --git a/models/login.go b/models/login.go index 3efef2f78f..984a9f8c30 100644 --- a/models/login.go +++ b/models/login.go @@ -150,8 +150,8 @@ func DelLoginSource(source *LoginSource) error { return err } -// login a user -func LoginUser(uname, passwd string) (*User, error) { +// UserSignIn validates user name and password. +func UserSignIn(uname, passwd string) (*User, error) { var u *User if strings.Contains(uname, "@") { u = &User{Email: uname} diff --git a/models/user.go b/models/user.go index f95f303b2b..78ab464249 100644 --- a/models/user.go +++ b/models/user.go @@ -72,7 +72,7 @@ func (user *User) HomeLink() string { return "/user/" + user.Name } -// AvatarLink returns the user gravatar link. +// AvatarLink returns user gravatar link. func (user *User) AvatarLink() string { if setting.DisableGravatar { return "/img/avatar_default.jpg" @@ -268,17 +268,17 @@ func ChangeUserName(user *User, newUserName string) (err error) { } // UpdateUser updates user's information. -func UpdateUser(user *User) (err error) { - user.LowerName = strings.ToLower(user.Name) +func UpdateUser(u *User) (err error) { + u.LowerName = strings.ToLower(u.Name) - if len(user.Location) > 255 { - user.Location = user.Location[:255] + if len(u.Location) > 255 { + u.Location = u.Location[:255] } - if len(user.Website) > 255 { - user.Website = user.Website[:255] + if len(u.Website) > 255 { + u.Website = u.Website[:255] } - _, err = orm.Id(user.Id).AllCols().Update(user) + _, err = orm.Id(u.Id).AllCols().Update(u) return err } @@ -356,17 +356,16 @@ func GetUserByKeyId(keyId int64) (*User, error) { return user, nil } -// GetUserById returns the user object by given id if exists. +// GetUserById returns the user object by given ID if exists. func GetUserById(id int64) (*User, error) { - user := new(User) - has, err := orm.Id(id).Get(user) + u := new(User) + has, err := orm.Id(id).Get(u) if err != nil { return nil, err - } - if !has { + } else if !has { return nil, ErrUserNotExist } - return user, nil + return u, nil } // GetUserByName returns the user object by given name if exists. |