aboutsummaryrefslogtreecommitdiff
path: root/modules/auth/user.go
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-03-17 14:03:58 -0400
committerUnknown <joe2010xtmf@163.com>2014-03-17 14:03:58 -0400
commite51afe4621cfbc8380994c818981f42a097e3ec5 (patch)
tree74e26a6c8fa60ab82f9f1e791693cd178adc5a10 /modules/auth/user.go
parent9d3b003add6bee6cb23cbac5d32f6fb3d4fd50cb (diff)
Add postgres support, clean code, code review
Diffstat (limited to 'modules/auth/user.go')
-rw-r--r--modules/auth/user.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/modules/auth/user.go b/modules/auth/user.go
index 21336cdd..491ec65a 100644
--- a/modules/auth/user.go
+++ b/modules/auth/user.go
@@ -18,6 +18,7 @@ import (
"github.com/gogits/gogs/modules/log"
)
+// SignedInId returns the id of signed in user.
func SignedInId(session sessions.Session) int64 {
userId := session.Get("userId")
if userId == nil {
@@ -32,6 +33,7 @@ func SignedInId(session sessions.Session) int64 {
return 0
}
+// SignedInName returns the name of signed in user.
func SignedInName(session sessions.Session) string {
userName := session.Get("userName")
if userName == nil {
@@ -43,6 +45,7 @@ func SignedInName(session sessions.Session) string {
return ""
}
+// SignedInUser returns the user object of signed user.
func SignedInUser(session sessions.Session) *models.User {
id := SignedInId(session)
if id <= 0 {
@@ -57,6 +60,7 @@ func SignedInUser(session sessions.Session) *models.User {
return user
}
+// IsSignedIn check if any user has signed in.
func IsSignedIn(session sessions.Session) bool {
return SignedInId(session) > 0
}