mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-16 20:00:03 +02:00
Fix ignored errors when checking if organization, team member (#3177)
This commit is contained in:
parent
529482135c
commit
515cdaa85d
16 changed files with 281 additions and 144 deletions
|
@ -1493,12 +1493,18 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error
|
|||
// Dummy object.
|
||||
collaboration := &Collaboration{RepoID: repo.ID}
|
||||
for _, c := range collaborators {
|
||||
collaboration.UserID = c.ID
|
||||
if c.ID == newOwner.ID || newOwner.IsOrgMember(c.ID) {
|
||||
if _, err = sess.Delete(collaboration); err != nil {
|
||||
return fmt.Errorf("remove collaborator '%d': %v", c.ID, err)
|
||||
if c.ID != newOwner.ID {
|
||||
isMember, err := newOwner.IsOrgMember(c.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("IsOrgMember: %v", err)
|
||||
} else if !isMember {
|
||||
continue
|
||||
}
|
||||
}
|
||||
collaboration.UserID = c.ID
|
||||
if _, err = sess.Delete(collaboration); err != nil {
|
||||
return fmt.Errorf("remove collaborator '%d': %v", c.ID, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Remove old team-repository relations.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue