forked from mirrors/forgejo
fix: make lastcommit available for non-signed-in users (#10815)
- Regression of forgejo/forgejo!9830 - `reqSignIn` means it requires sign-in, but it does not require sign-in (can be hit by visiting large repository) so `ignSignIn` is the better option. - Resulted in behavior of being redirected to `/user/login` when visiting a repository such as comaps or forgejo when not being logged in. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10815 Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
parent
1dceb23868
commit
e3bb1589c3
2 changed files with 17 additions and 1 deletions
|
|
@ -1655,7 +1655,7 @@ func registerRoutes(m *web.Route) {
|
|||
m.Post("/sync_fork", context.RepoMustNotBeArchived(), repo.MustBeNotEmpty, reqRepoCodeWriter, repo.SyncFork)
|
||||
}, ignSignIn, context.RepoAssignment, context.UnitTypes())
|
||||
|
||||
m.Post("/{username}/{reponame}/lastcommit/*", reqSignIn, context.RepoAssignment, context.UnitTypes(), context.RepoRefByType(context.RepoRefCommit), reqRepoCodeReader, repo.LastCommit)
|
||||
m.Post("/{username}/{reponame}/lastcommit/*", ignSignIn, context.RepoAssignment, context.UnitTypes(), context.RepoRefByType(context.RepoRefCommit), reqRepoCodeReader, repo.LastCommit)
|
||||
|
||||
m.Group("/{username}/{reponame}", func() {
|
||||
if !setting.Repository.DisableStars {
|
||||
|
|
|
|||
|
|
@ -82,3 +82,19 @@ func TestRepoCommitHeader(t *testing.T) {
|
|||
assert.Equal(t, commit.ID.String()[:10], sha.Find(".shortsha").Text())
|
||||
})
|
||||
}
|
||||
|
||||
func TestLastCommit(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
t.Run("Anonymous", func(t *testing.T) {
|
||||
req := NewRequest(t, "POST", "/user2/repo1/lastcommit/65f1bf27bc3bf70f64657658635e66094edbcb4d")
|
||||
MakeRequest(t, req, http.StatusOK)
|
||||
})
|
||||
|
||||
t.Run("Signed in", func(t *testing.T) {
|
||||
session := loginUser(t, "user2")
|
||||
|
||||
req := NewRequest(t, "POST", "/user2/repo1/lastcommit/65f1bf27bc3bf70f64657658635e66094edbcb4d")
|
||||
session.MakeRequest(t, req, http.StatusOK)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue