Skip to content

Commit

Permalink
API should follow RequireSignInView (go-gitea#8654)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Oct 24, 2019
1 parent 63c54f7 commit 4b040a4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion routers/api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/topics", func() {
m.Get("/search", repo.TopicSearch)
})
}, securityHeaders(), context.APIContexter(), sudo())
}, securityHeaders(), reqTokenBySetting(), context.APIContexter(), sudo())
}

func securityHeaders() macaron.Handler {
Expand All @@ -857,3 +857,10 @@ func securityHeaders() macaron.Handler {
})
}
}

func reqTokenBySetting() macaron.Handler {
if setting.Service.RequireSignInView {
return reqToken()
}
return func(ctx *macaron.Context) {}
}

0 comments on commit 4b040a4

Please sign in to comment.