1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-11-24 08:02:18 +02:00

fixed panic that issues csrf token when user not authenticated

This commit is contained in:
Brad Rydzewski 2015-09-30 18:42:32 -07:00
parent ad63fc7060
commit 874924218f

View File

@ -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,
})
}