forked from kevadesu/forgejo
Recalculate repository access only for specific user (#8481)
* Recalculate repository access only for specific user Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Handle user repositories as well, and only add access if minimum mode * Need to get repo owner to check if organization
This commit is contained in:
parent
733c898a90
commit
8ad2697611
3 changed files with 64 additions and 8 deletions
|
@ -41,12 +41,7 @@ func (repo *Repository) AddCollaborator(u *User) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if repo.Owner.IsOrganization() {
|
||||
err = repo.recalculateTeamAccesses(sess, 0)
|
||||
} else {
|
||||
err = repo.recalculateAccesses(sess)
|
||||
}
|
||||
if err != nil {
|
||||
if err = repo.recalculateUserAccess(sess, u.ID); err != nil {
|
||||
return fmt.Errorf("recalculateAccesses 'team=%v': %v", repo.Owner.IsOrganization(), err)
|
||||
}
|
||||
|
||||
|
@ -89,6 +84,18 @@ func (repo *Repository) GetCollaborators() ([]*Collaborator, error) {
|
|||
return repo.getCollaborators(x)
|
||||
}
|
||||
|
||||
func (repo *Repository) getCollaboration(e Engine, uid int64) (*Collaboration, error) {
|
||||
collaboration := &Collaboration{
|
||||
RepoID: repo.ID,
|
||||
UserID: uid,
|
||||
}
|
||||
has, err := e.Get(collaboration)
|
||||
if !has {
|
||||
collaboration = nil
|
||||
}
|
||||
return collaboration, err
|
||||
}
|
||||
|
||||
func (repo *Repository) isCollaborator(e Engine, userID int64) (bool, error) {
|
||||
return e.Get(&Collaboration{RepoID: repo.ID, UserID: userID})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue