mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Fix API leaking Usermail if not logged in (#25097)
The API should only return the real Mail of a User, if the caller is logged in. The check do to this don't work. This PR fixes this. This not really a security issue, but can lead to Spam. --------- Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
		| @@ -4,14 +4,12 @@ | ||||
| package integration | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"net/http" | ||||
| 	"testing" | ||||
|  | ||||
| 	auth_model "code.gitea.io/gitea/models/auth" | ||||
| 	"code.gitea.io/gitea/models/unittest" | ||||
| 	user_model "code.gitea.io/gitea/models/user" | ||||
| 	"code.gitea.io/gitea/modules/setting" | ||||
| 	api "code.gitea.io/gitea/modules/structs" | ||||
| 	"code.gitea.io/gitea/tests" | ||||
|  | ||||
| @@ -54,11 +52,7 @@ func TestAPIUserSearchNotLoggedIn(t *testing.T) { | ||||
| 	for _, user := range results.Data { | ||||
| 		assert.Contains(t, user.UserName, query) | ||||
| 		modelUser = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: user.ID}) | ||||
| 		if modelUser.KeepEmailPrivate { | ||||
| 			assert.EqualValues(t, fmt.Sprintf("%s@%s", modelUser.LowerName, setting.Service.NoReplyAddress), user.Email) | ||||
| 		} else { | ||||
| 			assert.EqualValues(t, modelUser.Email, user.Email) | ||||
| 		} | ||||
| 		assert.EqualValues(t, modelUser.GetPlaceholderEmail(), user.Email) | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user