From 9cdded911b62825e448ee9e94b0b534351d4b3d8 Mon Sep 17 00:00:00 2001 From: slene Date: Sat, 15 Mar 2014 20:50:17 +0800 Subject: [PATCH] fix context --- modules/middleware/context.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/middleware/context.go b/modules/middleware/context.go index 5ca726d93efb..3167823794b4 100644 --- a/modules/middleware/context.go +++ b/modules/middleware/context.go @@ -60,12 +60,15 @@ func InitContext() martini.Handler { // Get user from session if logined. user := auth.SignedInUser(session) ctx.User = user - ctx.IsSigned = ctx != nil + ctx.IsSigned = user != nil - data["IsSigned"] = true - data["SignedUser"] = user - data["SignedUserId"] = user.Id - data["SignedUserName"] = user.LowerName + data["IsSigned"] = ctx.IsSigned + + if user != nil { + data["SignedUser"] = user + data["SignedUserId"] = user.Id + data["SignedUserName"] = user.LowerName + } c.Map(ctx) c.Map(data)