Skip to content

Commit

Permalink
API should follow RequireSignInView (#8654)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored Oct 24, 2019
1 parent bd7709a commit 3c63c3a
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 @@ -862,7 +862,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 @@ -874,3 +874,10 @@ func securityHeaders() macaron.Handler {
})
}
}

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

0 comments on commit 3c63c3a

Please sign in to comment.