mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-13 06:20:24 +00:00
[v14.0/forgejo] fix: make lastcommit available for non-signed-in users (#10817)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/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. Co-authored-by: Gusted <postmaster@gusted.xyz> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10817 Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org> Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org> Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
This commit is contained in:
parent
48bb631f20
commit
527c1a4fda
2 changed files with 17 additions and 1 deletions
|
|
@ -1654,7 +1654,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