1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-14 14:37:20 +00:00

Fix bug preventing transfer to private organization (#12497) (#12501)

* Fix bug preventing transfer to private organization

The code assessing whether a private organization was visible to a user before
allowing transfer was incorrect due to testing membership the wrong way round

This PR fixes this issue and renames the function performing the test to be
clearer.

Further looking at the API for transfer repository - no testing was
performed to ensure that the acting user could actually see the new
owning organization.

Signed-off-by: Andrew Thornton <art27@cantab.net>

* change IsUserPartOfOrg everywhere

Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
techknowlogick
2020-08-17 02:32:33 -04:00
committed by GitHub
parent f0dd07129a
commit ec48618d40
5 changed files with 17 additions and 8 deletions

View File

@ -609,12 +609,12 @@ func (u *User) IsUserOrgOwner(orgID int64) bool {
return isOwner
}
// IsUserPartOfOrg returns true if user with userID is part of the u organisation.
func (u *User) IsUserPartOfOrg(userID int64) bool {
return u.isUserPartOfOrg(x, userID)
// HasMemberWithUserID returns true if user with userID is part of the u organisation.
func (u *User) HasMemberWithUserID(userID int64) bool {
return u.hasMemberWithUserID(x, userID)
}
func (u *User) isUserPartOfOrg(e Engine, userID int64) bool {
func (u *User) hasMemberWithUserID(e Engine, userID int64) bool {
isMember, err := isOrganizationMember(e, u.ID, userID)
if err != nil {
log.Error("IsOrganizationMember: %v", err)