mirror of
https://github.com/gogs/gogs.git
synced 2025-05-24 16:30:51 +00:00
repo: users have access to base repository can also view forks (#6261)
This commit is contained in:
parent
bc8428ca42
commit
178b73fecd
@ -55,6 +55,7 @@ All notable changes to Gogs are documented in this file.
|
|||||||
- Disallow multiple tokens with same name. [#5587](https://github.com/gogs/gogs/issues/5587) [#5820](https://github.com/gogs/gogs/pull/5820)
|
- Disallow multiple tokens with same name. [#5587](https://github.com/gogs/gogs/issues/5587) [#5820](https://github.com/gogs/gogs/pull/5820)
|
||||||
- Enable Federated Avatar Lookup could cause server to crash. [#5848](https://github.com/gogs/gogs/issues/5848)
|
- Enable Federated Avatar Lookup could cause server to crash. [#5848](https://github.com/gogs/gogs/issues/5848)
|
||||||
- Private repositories are hidden in the organization's view. [#5869](https://github.com/gogs/gogs/issues/5869)
|
- Private repositories are hidden in the organization's view. [#5869](https://github.com/gogs/gogs/issues/5869)
|
||||||
|
- Users have access to base repository cannot view commits in forks. [#5878](https://github.com/gogs/gogs/issues/5878)
|
||||||
- Server error when changing email address in user settings page. [#5899](https://github.com/gogs/gogs/issues/5899)
|
- Server error when changing email address in user settings page. [#5899](https://github.com/gogs/gogs/issues/5899)
|
||||||
- Fall back to use RFC 3339 as time layout when misconfigured. [#6098](https://github.com/gogs/gogs/issues/6098)
|
- Fall back to use RFC 3339 as time layout when misconfigured. [#6098](https://github.com/gogs/gogs/issues/6098)
|
||||||
- Unable to update team with server error. [#6185](https://github.com/gogs/gogs/issues/6185)
|
- Unable to update team with server error. [#6185](https://github.com/gogs/gogs/issues/6185)
|
||||||
|
@ -166,11 +166,11 @@ func RepoAssignment(pages ...bool) macaron.Handler {
|
|||||||
c.Data["RepoLink"] = c.Repo.RepoLink
|
c.Data["RepoLink"] = c.Repo.RepoLink
|
||||||
c.Data["RepoRelPath"] = c.Repo.Owner.Name + "/" + c.Repo.Repository.Name
|
c.Data["RepoRelPath"] = c.Repo.Owner.Name + "/" + c.Repo.Repository.Name
|
||||||
|
|
||||||
// Admin has super access.
|
// Admin has super access
|
||||||
if c.IsLogged && c.User.IsAdmin {
|
if c.IsLogged && c.User.IsAdmin {
|
||||||
c.Repo.AccessMode = db.AccessModeOwner
|
c.Repo.AccessMode = db.AccessModeOwner
|
||||||
} else {
|
} else {
|
||||||
mode, err := db.UserAccessMode(c.UserID(), repo)
|
mode, err := db.UserAccessMode(c.UserID(), c.Repo.Repository)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Error(err, "get user access mode")
|
c.Error(err, "get user access mode")
|
||||||
return
|
return
|
||||||
@ -178,6 +178,21 @@ func RepoAssignment(pages ...bool) macaron.Handler {
|
|||||||
c.Repo.AccessMode = mode
|
c.Repo.AccessMode = mode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the authenticated user has no direct access, see if the repository is a fork
|
||||||
|
// and whether the user has access to the base repository.
|
||||||
|
if c.Repo.AccessMode == db.AccessModeNone && c.Repo.Repository.IsFork {
|
||||||
|
mode, err := db.UserAccessMode(c.UserID(), c.Repo.Repository.BaseRepo)
|
||||||
|
if err != nil {
|
||||||
|
c.Error(err, "get user access mode of base repository")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Users shouldn't have indirect access level higher than write.
|
||||||
|
if mode > db.AccessModeWrite {
|
||||||
|
mode = db.AccessModeWrite
|
||||||
|
}
|
||||||
|
c.Repo.AccessMode = mode
|
||||||
|
}
|
||||||
|
|
||||||
// Check access
|
// Check access
|
||||||
if c.Repo.AccessMode == db.AccessModeNone {
|
if c.Repo.AccessMode == db.AccessModeNone {
|
||||||
// Redirect to any accessible page if not yet on it
|
// Redirect to any accessible page if not yet on it
|
||||||
|
Loading…
x
Reference in New Issue
Block a user