Refresh token before loading branches (#4284)

This commit is contained in:
qwerty287 2024-11-02 20:38:57 +02:00 committed by GitHub
parent 560eab96f0
commit 6ef7cddde8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -28,6 +28,7 @@ import (
"github.com/rs/zerolog/log"
"go.woodpecker-ci.org/woodpecker/v2/server"
"go.woodpecker-ci.org/woodpecker/v2/server/forge"
"go.woodpecker-ci.org/woodpecker/v2/server/model"
"go.woodpecker-ci.org/woodpecker/v2/server/router/middleware/session"
"go.woodpecker-ci.org/woodpecker/v2/server/store"
@ -359,6 +360,7 @@ func GetRepoPermissions(c *gin.Context) {
// @Param page query int false "for response pagination, page offset number" default(1)
// @Param perPage query int false "for response pagination, max items per page" default(50)
func GetRepoBranches(c *gin.Context) {
_store := store.FromContext(c)
repo := session.Repo(c)
user := session.User(c)
_forge, err := server.Config.Services.Manager.ForgeFromRepo(repo)
@ -368,6 +370,8 @@ func GetRepoBranches(c *gin.Context) {
return
}
forge.Refresh(c, _forge, _store, user)
branches, err := _forge.Branches(c, user, repo, session.Pagination(c))
if err != nil {
log.Error().Err(err).Msg("failed to load branches")
@ -390,6 +394,7 @@ func GetRepoBranches(c *gin.Context) {
// @Param page query int false "for response pagination, page offset number" default(1)
// @Param perPage query int false "for response pagination, max items per page" default(50)
func GetRepoPullRequests(c *gin.Context) {
_store := store.FromContext(c)
repo := session.Repo(c)
user := session.User(c)
_forge, err := server.Config.Services.Manager.ForgeFromRepo(repo)
@ -399,6 +404,8 @@ func GetRepoPullRequests(c *gin.Context) {
return
}
forge.Refresh(c, _forge, _store, user)
prs, err := _forge.PullRequests(c, user, repo, session.Pagination(c))
if err != nil {
_ = c.AbortWithError(http.StatusInternalServerError, err)