summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2014-03-06 16:17:15 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2014-03-06 16:17:15 +0800
commit35bff9e66122a6b8ca9e96cbd3e17c77d7601769 (patch)
tree465e1ad652f4798152b9e038a1898e4c3cf32986 /routers
parentc6f2c23b05474d80ea282a7683135b3ea8f8e2d9 (diff)
downloadgitea-35bff9e66122a6b8ca9e96cbd3e17c77d7601769.tar.gz
gitea-35bff9e66122a6b8ca9e96cbd3e17c77d7601769.zip
add IsSignedIn & SignedInName funcs
Diffstat (limited to 'routers')
-rw-r--r--routers/user/user.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/routers/user/user.go b/routers/user/user.go
index 503ebf54f4..811500ac9c 100644
--- a/routers/user/user.go
+++ b/routers/user/user.go
@@ -25,6 +25,28 @@ func Profile(r render.Render) {
return
}
+func IsSignedIn(session sessions.Session) bool {
+ id := session.Get("userId")
+ if id == nil {
+ return false
+ }
+ if s, ok := id.(int64); ok && s > 0 {
+ return true
+ }
+ return false
+}
+
+func SignedInName(session sessions.Session) string {
+ userName := session.Get("userName")
+ if userName == nil {
+ return ""
+ }
+ if s, ok := userName.(string); ok {
+ return s
+ }
+ return ""
+}
+
func SignIn(req *http.Request, r render.Render, session sessions.Session) {
var (
errString string