forked from forgejo/forgejo
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:
parent
7dc2e50113
commit
ea385f5d39
4 changed files with 24 additions and 9 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue