mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 23:44:06 +01:00
fix bug when users have serval teams with different units on different repositories (#5307)
This commit is contained in:
parent
599adde1bc
commit
c5d098c32e
2 changed files with 11 additions and 1 deletions
|
@ -525,6 +525,16 @@ func getUserTeams(e Engine, orgID, userID int64) (teams []*Team, err error) {
|
|||
Find(&teams)
|
||||
}
|
||||
|
||||
func getUserRepoTeams(e Engine, orgID, userID, repoID int64) (teams []*Team, err error) {
|
||||
return teams, e.
|
||||
Join("INNER", "team_user", "team_user.team_id = team.id").
|
||||
Join("INNER", "team_repo", "team_repo.team_id = team.id").
|
||||
Where("team.org_id = ?", orgID).
|
||||
And("team_user.uid=?", userID).
|
||||
And("team_repo.repo_id=?", repoID).
|
||||
Find(&teams)
|
||||
}
|
||||
|
||||
// GetUserTeams returns all teams that user belongs to in given organization.
|
||||
func GetUserTeams(orgID, userID int64) ([]*Team, error) {
|
||||
return getUserTeams(x, orgID, userID)
|
||||
|
|
|
@ -364,7 +364,7 @@ func (repo *Repository) getUnitsByUserID(e Engine, userID int64, isAdmin bool) (
|
|||
return nil
|
||||
}
|
||||
|
||||
teams, err := getUserTeams(e, repo.OwnerID, userID)
|
||||
teams, err := getUserRepoTeams(e, repo.OwnerID, userID, repo.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue