Skip to content

Commit df9a62b

Browse files
authored
Fix 404 error when leaving the last private org team (#24322)
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.
1 parent f1a4330 commit df9a62b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

routers/web/org/teams.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,17 @@ func TeamsAction(ctx *context.Context) {
8686
return
8787
}
8888
}
89+
90+
redirect := ctx.Org.OrgLink + "/teams/"
91+
if isOrgMember, err := org_model.IsOrganizationMember(ctx, ctx.Org.Organization.ID, ctx.Doer.ID); err != nil {
92+
ctx.ServerError("IsOrganizationMember", err)
93+
return
94+
} else if !isOrgMember {
95+
redirect = setting.AppSubURL + "/"
96+
}
8997
ctx.JSON(http.StatusOK,
9098
map[string]interface{}{
91-
"redirect": ctx.Org.OrgLink + "/teams/",
99+
"redirect": redirect,
92100
})
93101
return
94102
case "remove":

0 commit comments

Comments
 (0)