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 /modules/auth | |
parent | 11f9d738e8a1bce4c35bc5e1c37f5a7d1bcded5c (diff) | |
download | gitea-4f2f3c285717eff7a2f4ae2b79fbb0809e786dc8.tar.gz gitea-4f2f3c285717eff7a2f4ae2b79fbb0809e786dc8.zip |
Code convention
Diffstat (limited to 'modules/auth')
-rw-r--r-- | modules/auth/user.go | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/modules/auth/user.go b/modules/auth/user.go index e672a9c10f..3763c0fc64 100644 --- a/modules/auth/user.go +++ b/modules/auth/user.go @@ -19,54 +19,54 @@ import ( ) // SignedInId returns the id of signed in user. -func SignedInId(session session.SessionStore) int64 { +func SignedInId(sess session.SessionStore) int64 { if !models.HasEngine { return 0 } - userId := session.Get("userId") - if userId == nil { + uid := sess.Get("userId") + if uid == nil { return 0 } - if s, ok := userId.(int64); ok { - if _, err := models.GetUserById(s); err != nil { + if id, ok := uid.(int64); ok { + if _, err := models.GetUserById(id); err != nil { return 0 } - return s + return id } return 0 } // SignedInName returns the name of signed in user. -func SignedInName(session session.SessionStore) string { - userName := session.Get("userName") - if userName == nil { +func SignedInName(sess session.SessionStore) string { + uname := sess.Get("userName") + if uname == nil { return "" } - if s, ok := userName.(string); ok { + if s, ok := uname.(string); ok { return s } return "" } // SignedInUser returns the user object of signed user. -func SignedInUser(session session.SessionStore) *models.User { - id := SignedInId(session) - if id <= 0 { +func SignedInUser(sess session.SessionStore) *models.User { + uid := SignedInId(sess) + if uid <= 0 { return nil } - user, err := models.GetUserById(id) + u, err := models.GetUserById(uid) if err != nil { log.Error("user.SignedInUser: %v", err) return nil } - return user + return u } // IsSignedIn check if any user has signed in. -func IsSignedIn(session session.SessionStore) bool { - return SignedInId(session) > 0 +func IsSignedIn(sess session.SessionStore) bool { + return SignedInId(sess) > 0 } type FeedsForm struct { |