mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	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.
This commit is contained in:
		@@ -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":
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user