mirror of
https://github.com/go-gitea/gitea
synced 2024-11-23 02:28:15 +01:00
fix panic, add repo check, signed check
This commit is contained in:
parent
eb6021f73f
commit
8b700e825b
1 changed files with 26 additions and 1 deletions
|
@ -18,6 +18,10 @@ import (
|
|||
)
|
||||
|
||||
func Issues(ctx *middleware.Context) {
|
||||
if !ctx.Repo.IsValid {
|
||||
ctx.Handle(404, "issue.Issues(invalid repo):", nil)
|
||||
}
|
||||
|
||||
ctx.Data["Title"] = "Issues"
|
||||
ctx.Data["IsRepoToolbarIssues"] = true
|
||||
ctx.Data["IsRepoToolbarIssuesList"] = true
|
||||
|
@ -26,12 +30,17 @@ func Issues(ctx *middleware.Context) {
|
|||
milestoneId, _ := base.StrTo(ctx.Query("milestone")).Int()
|
||||
page, _ := base.StrTo(ctx.Query("page")).Int()
|
||||
|
||||
ctx.Data["IssueCreatedCount"] = 0
|
||||
|
||||
var posterId int64 = 0
|
||||
if ctx.Query("type") == "created_by" {
|
||||
if !ctx.IsSigned {
|
||||
ctx.Redirect("/user/login/", 302)
|
||||
}
|
||||
posterId = ctx.User.Id
|
||||
ctx.Data["ViewType"] = "created_by"
|
||||
ctx.Data["IssueCreatedCount"] = models.GetUserIssueCount(posterId, ctx.Repo.Repository.Id)
|
||||
}
|
||||
ctx.Data["IssueCreatedCount"] = models.GetUserIssueCount(ctx.User.Id, ctx.Repo.Repository.Id)
|
||||
|
||||
// Get issues.
|
||||
issues, err := models.GetIssues(0, ctx.Repo.Repository.Id, posterId, int64(milestoneId), page,
|
||||
|
@ -60,6 +69,10 @@ func Issues(ctx *middleware.Context) {
|
|||
}
|
||||
|
||||
func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.CreateIssueForm) {
|
||||
if !ctx.Repo.IsValid {
|
||||
ctx.Handle(404, "issue.CreateIssue(invalid repo):", nil)
|
||||
}
|
||||
|
||||
ctx.Data["Title"] = "Create issue"
|
||||
ctx.Data["IsRepoToolbarIssues"] = true
|
||||
ctx.Data["IsRepoToolbarIssuesList"] = false
|
||||
|
@ -102,6 +115,10 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
|
|||
}
|
||||
|
||||
func ViewIssue(ctx *middleware.Context, params martini.Params) {
|
||||
if !ctx.Repo.IsValid {
|
||||
ctx.Handle(404, "issue.ViewIssue(invalid repo):", nil)
|
||||
}
|
||||
|
||||
index, err := base.StrTo(params["index"]).Int()
|
||||
if err != nil {
|
||||
ctx.Handle(404, "issue.ViewIssue", err)
|
||||
|
@ -154,6 +171,10 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) {
|
|||
}
|
||||
|
||||
func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.CreateIssueForm) {
|
||||
if !ctx.Repo.IsValid {
|
||||
ctx.Handle(404, "issue.UpdateIssue(invalid repo):", nil)
|
||||
}
|
||||
|
||||
index, err := base.StrTo(params["index"]).Int()
|
||||
if err != nil {
|
||||
ctx.Handle(404, "issue.UpdateIssue", err)
|
||||
|
@ -190,6 +211,10 @@ func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
|
|||
}
|
||||
|
||||
func Comment(ctx *middleware.Context, params martini.Params) {
|
||||
if !ctx.Repo.IsValid {
|
||||
ctx.Handle(404, "issue.Comment(invalid repo):", nil)
|
||||
}
|
||||
|
||||
index, err := base.StrTo(ctx.Query("issueIndex")).Int()
|
||||
if err != nil {
|
||||
ctx.Handle(404, "issue.Comment", err)
|
||||
|
|
Loading…
Reference in a new issue