summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-06-17 23:38:24 -0400
committerLunny Xiao <xiaolunwen@gmail.com>2017-06-18 11:38:24 +0800
commit4df1a240965f6d3f4e3eed2bd4bddceeb9182614 (patch)
treeabf4a9e3bb405bff503cbb661c6fbeeb3aaf9d0f /routers
parent6e452c4da7400495b3298c3c9477378249c9cd9e (diff)
downloadgitea-4df1a240965f6d3f4e3eed2bd4bddceeb9182614.tar.gz
gitea-4df1a240965f6d3f4e3eed2bd4bddceeb9182614.zip
Let not-logged-in users view releases (#1999)
Diffstat (limited to 'routers')
-rw-r--r--routers/repo/release.go5
-rw-r--r--routers/routes/routes.go8
2 files changed, 9 insertions, 4 deletions
diff --git a/routers/repo/release.go b/routers/repo/release.go
index 70a310cc13..093fec539a 100644
--- a/routers/repo/release.go
+++ b/routers/repo/release.go
@@ -79,7 +79,10 @@ func Releases(ctx *context.Context) {
// Temporary cache commits count of used branches to speed up.
countCache := make(map[string]int64)
- cacheUsers := map[int64]*models.User{ctx.User.ID: ctx.User}
+ cacheUsers := make(map[int64]*models.User)
+ if ctx.User != nil {
+ cacheUsers[ctx.User.ID] = ctx.User
+ }
var ok bool
releasesToDisplay := make([]*models.Release, 0, len(releases))
diff --git a/routers/routes/routes.go b/routers/routes/routes.go
index c45cfd0e0c..c2f29613b4 100644
--- a/routers/routes/routes.go
+++ b/routers/routes/routes.go
@@ -529,14 +529,16 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/:username/:reponame", func() {
m.Group("/releases", func() {
m.Get("/", repo.MustBeNotBare, repo.Releases)
+ }, repo.MustBeNotBare, context.RepoRef())
+ m.Group("/releases", func() {
m.Get("/new", repo.NewRelease)
m.Post("/new", bindIgnErr(auth.NewReleaseForm{}), repo.NewReleasePost)
m.Post("/delete", repo.DeleteRelease)
- }, repo.MustBeNotBare, reqRepoWriter, context.RepoRef())
+ }, reqSignIn, repo.MustBeNotBare, reqRepoWriter, context.RepoRef())
m.Group("/releases", func() {
m.Get("/edit/*", repo.EditRelease)
m.Post("/edit/*", bindIgnErr(auth.EditReleaseForm{}), repo.EditReleasePost)
- }, repo.MustBeNotBare, reqRepoWriter, func(ctx *context.Context) {
+ }, reqSignIn, repo.MustBeNotBare, reqRepoWriter, func(ctx *context.Context) {
var err error
ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
if err != nil {
@@ -550,7 +552,7 @@ func RegisterRoutes(m *macaron.Macaron) {
}
ctx.Data["CommitsCount"] = ctx.Repo.CommitsCount
})
- }, reqSignIn, context.RepoAssignment(), context.UnitTypes(), context.LoadRepoUnits(), context.CheckUnit(models.UnitTypeReleases))
+ }, context.RepoAssignment(), context.UnitTypes(), context.LoadRepoUnits(), context.CheckUnit(models.UnitTypeReleases))
m.Group("/:username/:reponame", func() {
m.Group("", func() {