mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-09 00:55:32 +00:00
parent
2961aaf72b
commit
b4acbafffc
1 changed files with 5 additions and 4 deletions
|
@ -46,12 +46,13 @@ func HandleLogin(c *gin.Context) {
|
|||
|
||||
func HandleAuth(c *gin.Context) {
|
||||
_store := store.FromContext(c)
|
||||
_forge := server.Config.Services.Forge
|
||||
|
||||
// when dealing with redirects we may need to adjust the content type. I
|
||||
// cannot, however, remember why, so need to revisit this line.
|
||||
c.Writer.Header().Del("Content-Type")
|
||||
|
||||
tmpuser, err := server.Config.Services.Forge.Login(c, c.Writer, c.Request)
|
||||
tmpuser, err := _forge.Login(c, c.Writer, c.Request)
|
||||
if err != nil {
|
||||
log.Error().Msgf("cannot authenticate user. %s", err)
|
||||
c.Redirect(http.StatusSeeOther, "/login?error=oauth_error")
|
||||
|
@ -82,7 +83,7 @@ func HandleAuth(c *gin.Context) {
|
|||
// if self-registration is enabled for whitelisted organizations we need to
|
||||
// check the user's organization membership.
|
||||
if len(config.Orgs) != 0 {
|
||||
teams, terr := server.Config.Services.Forge.Teams(c, tmpuser)
|
||||
teams, terr := _forge.Teams(c, tmpuser)
|
||||
if terr != nil || !config.IsMember(teams) {
|
||||
log.Error().Msgf("cannot verify team membership for %s.", u.Login)
|
||||
c.Redirect(303, "/login?error=access_denied")
|
||||
|
@ -123,7 +124,7 @@ func HandleAuth(c *gin.Context) {
|
|||
// if self-registration is enabled for whitelisted organizations we need to
|
||||
// check the user's organization membership.
|
||||
if len(config.Orgs) != 0 {
|
||||
teams, terr := server.Config.Services.Forge.Teams(c, u)
|
||||
teams, terr := _forge.Teams(c, u)
|
||||
if terr != nil || !config.IsMember(teams) {
|
||||
log.Error().Msgf("cannot verify team membership for %s.", u.Login)
|
||||
c.Redirect(http.StatusSeeOther, "/login?error=access_denied")
|
||||
|
@ -145,7 +146,7 @@ func HandleAuth(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
repos, _ := server.Config.Services.Forge.Repos(c, u)
|
||||
repos, _ := _forge.Repos(c, u)
|
||||
for _, forgeRepo := range repos {
|
||||
dbRepo, err := _store.GetRepoForgeID(forgeRepo.ForgeRemoteID)
|
||||
if err != nil && errors.Is(err, types.RecordNotExist) {
|
||||
|
|
Loading…
Reference in a new issue