mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-27 07:56:13 +00:00
Fix repository owner can assign self
This commit is contained in:
parent
4042d1f0c3
commit
f3c3258921
@ -325,20 +325,19 @@ func (repo *Repository) getAssignees(e Engine) (_ []*User, err error) {
|
|||||||
if err = e.Where("repo_id = ? AND mode >= ?", repo.ID, ACCESS_MODE_WRITE).Find(&accesses); err != nil {
|
if err = e.Where("repo_id = ? AND mode >= ?", repo.ID, ACCESS_MODE_WRITE).Find(&accesses); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(accesses) == 0 {
|
|
||||||
return []*User{}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
userIDs := make([]int64, len(accesses))
|
|
||||||
for i := 0; i < len(accesses); i++ {
|
|
||||||
userIDs[i] = accesses[i].UserID
|
|
||||||
}
|
|
||||||
|
|
||||||
// Leave a seat for owner itself to append later, but if owner is an organization
|
// Leave a seat for owner itself to append later, but if owner is an organization
|
||||||
// and just waste 1 unit is cheaper than re-allocate memory once.
|
// and just waste 1 unit is cheaper than re-allocate memory once.
|
||||||
users := make([]*User, 0, len(userIDs)+1)
|
users := make([]*User, 0, len(accesses)+1)
|
||||||
if err = e.In("id", userIDs).Find(&users); err != nil {
|
if len(accesses) > 0 {
|
||||||
return nil, err
|
userIDs := make([]int64, len(accesses))
|
||||||
|
for i := 0; i < len(accesses); i++ {
|
||||||
|
userIDs[i] = accesses[i].UserID
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = e.In("id", userIDs).Find(&users); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if !repo.Owner.IsOrganization() {
|
if !repo.Owner.IsOrganization() {
|
||||||
users = append(users, repo.Owner)
|
users = append(users, repo.Owner)
|
||||||
|
Loading…
Reference in New Issue
Block a user