mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 00:20:25 +08:00 
			
		
		
		
	Re-enable transfer repo back from org to user account (#14807)
* re-enable transfer repo back from org to user account * add test case
This commit is contained in:
		@@ -450,6 +450,7 @@ func TestAPIRepoTransfer(t *testing.T) {
 | 
				
			|||||||
		{ctxUserID: 1, newOwner: "user2", teams: &[]int64{2}, expectedStatus: http.StatusUnprocessableEntity},
 | 
							{ctxUserID: 1, newOwner: "user2", teams: &[]int64{2}, expectedStatus: http.StatusUnprocessableEntity},
 | 
				
			||||||
		{ctxUserID: 1, newOwner: "user3", teams: &[]int64{5}, expectedStatus: http.StatusForbidden},
 | 
							{ctxUserID: 1, newOwner: "user3", teams: &[]int64{5}, expectedStatus: http.StatusForbidden},
 | 
				
			||||||
		{ctxUserID: 1, newOwner: "user3", teams: &[]int64{2}, expectedStatus: http.StatusAccepted},
 | 
							{ctxUserID: 1, newOwner: "user3", teams: &[]int64{2}, expectedStatus: http.StatusAccepted},
 | 
				
			||||||
 | 
							{ctxUserID: 2, newOwner: "user2", teams: nil, expectedStatus: http.StatusAccepted},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	defer prepareTestEnv(t)()
 | 
						defer prepareTestEnv(t)()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -80,8 +80,8 @@ func StartRepositoryTransfer(doer, newOwner *models.User, repo *models.Repositor
 | 
				
			|||||||
		return fmt.Errorf("repository is not ready for transfer")
 | 
							return fmt.Errorf("repository is not ready for transfer")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Admin is always allowed to transfer
 | 
						// Admin is always allowed to transfer || user transfer repo back to his account
 | 
				
			||||||
	if doer.IsAdmin {
 | 
						if doer.IsAdmin || doer.ID == newOwner.ID {
 | 
				
			||||||
		return TransferOwnership(doer, newOwner, repo, teams)
 | 
							return TransferOwnership(doer, newOwner, repo, teams)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user