mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-02 16:35:19 +02:00
Fix access issues on milestone and issue overview pages. (#9603)
* Fix access issues on milestone and issue overview pages. * Fix filter algorithm
This commit is contained in:
parent
8b24073713
commit
03d59bcd1d
3 changed files with 65 additions and 54 deletions
|
@ -369,3 +369,23 @@ func hasAccess(e Engine, userID int64, repo *Repository) (bool, error) {
|
|||
func HasAccess(userID int64, repo *Repository) (bool, error) {
|
||||
return hasAccess(x, userID, repo)
|
||||
}
|
||||
|
||||
// FilterOutRepoIdsWithoutUnitAccess filter out repos where user has no access to repositories
|
||||
func FilterOutRepoIdsWithoutUnitAccess(u *User, repoIDs []int64, units ...UnitType) ([]int64, error) {
|
||||
i := 0
|
||||
for _, rID := range repoIDs {
|
||||
repo, err := GetRepositoryByID(rID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
perm, err := GetUserRepoPermission(repo, u)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if perm.CanReadAny(units...) {
|
||||
repoIDs[i] = rID
|
||||
i++
|
||||
}
|
||||
}
|
||||
return repoIDs[:i], nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue