fixed panic that issues csrf token when user not authenticated
This commit is contained in:
parent
ad63fc7060
commit
874924218f
1 changed files with 8 additions and 5 deletions
|
@ -194,10 +194,13 @@ func ShowBuild(c *gin.Context) {
|
||||||
|
|
||||||
httputil.SetCookie(c.Writer, c.Request, "user_last", repo.FullName)
|
httputil.SetCookie(c.Writer, c.Request, "user_last", repo.FullName)
|
||||||
|
|
||||||
token, _ := token.New(
|
var csrf string
|
||||||
|
if user != nil {
|
||||||
|
csrf, _ = token.New(
|
||||||
token.CsrfToken,
|
token.CsrfToken,
|
||||||
user.Login,
|
user.Login,
|
||||||
).Sign(user.Hash)
|
).Sign(user.Hash)
|
||||||
|
}
|
||||||
|
|
||||||
c.HTML(200, "build.html", gin.H{
|
c.HTML(200, "build.html", gin.H{
|
||||||
"User": user,
|
"User": user,
|
||||||
|
@ -205,6 +208,6 @@ func ShowBuild(c *gin.Context) {
|
||||||
"Build": build,
|
"Build": build,
|
||||||
"Jobs": jobs,
|
"Jobs": jobs,
|
||||||
"Job": job,
|
"Job": job,
|
||||||
"Csrf": token,
|
"Csrf": csrf,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue