From 874924218fe05c28c87d114900a9583c779fe1aa Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Wed, 30 Sep 2015 18:42:32 -0700 Subject: [PATCH] fixed panic that issues csrf token when user not authenticated --- controller/index.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/controller/index.go b/controller/index.go index 5731d4af2..346829b6c 100644 --- a/controller/index.go +++ b/controller/index.go @@ -194,10 +194,13 @@ func ShowBuild(c *gin.Context) { httputil.SetCookie(c.Writer, c.Request, "user_last", repo.FullName) - token, _ := token.New( - token.CsrfToken, - user.Login, - ).Sign(user.Hash) + var csrf string + if user != nil { + csrf, _ = token.New( + token.CsrfToken, + user.Login, + ).Sign(user.Hash) + } c.HTML(200, "build.html", gin.H{ "User": user, @@ -205,6 +208,6 @@ func ShowBuild(c *gin.Context) { "Build": build, "Jobs": jobs, "Job": job, - "Csrf": token, + "Csrf": csrf, }) }