Skip to content

Commit

Permalink
Fix 404 error when leaving the last private org team (#24322)
Browse files Browse the repository at this point in the history
If the user only belongs to one org team and the org is private, 
leaving the org team will redirect to `ctx.Org.OrgLink + "/teams/"`
which is inaccessible.

So we need to check whether the user still belongs to the org.
  • Loading branch information
yp05327 authored Apr 26, 2023
1 parent f1a4330 commit df9a62b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion routers/web/org/teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,17 @@ func TeamsAction(ctx *context.Context) {
return
}
}

redirect := ctx.Org.OrgLink + "/teams/"
if isOrgMember, err := org_model.IsOrganizationMember(ctx, ctx.Org.Organization.ID, ctx.Doer.ID); err != nil {
ctx.ServerError("IsOrganizationMember", err)
return
} else if !isOrgMember {
redirect = setting.AppSubURL + "/"
}
ctx.JSON(http.StatusOK,
map[string]interface{}{
"redirect": ctx.Org.OrgLink + "/teams/",
"redirect": redirect,
})
return
case "remove":
Expand Down

0 comments on commit df9a62b

Please sign in to comment.