Documentation
¶
Index ¶
- func GetRepoReaders(repo *repo_model.Repository) (_ []*user_model.User, err error)
- func GetRepoWriters(repo *repo_model.Repository) (_ []*user_model.User, err error)
- func IsRepoReader(ctx context.Context, repo *repo_model.Repository, userID int64) (bool, error)
- func IsUserRealRepoAdmin(repo *repo_model.Repository, user *user_model.User) (bool, error)
- type Access
- type Permission
- func (p *Permission) CanAccess(mode perm_model.AccessMode, unitType unit.Type) bool
- func (p *Permission) CanAccessAny(mode perm_model.AccessMode, unitTypes ...unit.Type) bool
- func (p *Permission) CanRead(unitType unit.Type) bool
- func (p *Permission) CanReadAny(unitTypes ...unit.Type) bool
- func (p *Permission) CanReadIssuesOrPulls(isPull bool) bool
- func (p *Permission) CanWrite(unitType unit.Type) bool
- func (p *Permission) CanWriteIssuesOrPulls(isPull bool) bool
- func (p *Permission) HasAccess() bool
- func (p *Permission) IsAdmin() bool
- func (p *Permission) IsOwner() bool
- func (p *Permission) UnitAccessMode(unitType unit.Type) perm_model.AccessMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRepoReaders ¶
func GetRepoReaders(repo *repo_model.Repository) (_ []*user_model.User, err error)
GetRepoReaders returns all users that have explicit read access or higher to the repository.
func GetRepoWriters ¶
func GetRepoWriters(repo *repo_model.Repository) (_ []*user_model.User, err error)
GetRepoWriters returns all users that have write access to the repository.
func IsRepoReader ¶
func IsRepoReader(ctx context.Context, repo *repo_model.Repository, userID int64) (bool, error)
IsRepoReader returns true if user has explicit read access or higher to the repository.
func IsUserRealRepoAdmin ¶
func IsUserRealRepoAdmin(repo *repo_model.Repository, user *user_model.User) (bool, error)
IsUserRealRepoAdmin check if this user is real repo admin
Types ¶
type Access ¶
type Access struct { ID int64 `xorm:"pk autoincr"` UserID int64 `xorm:"UNIQUE(s)"` RepoID int64 `xorm:"UNIQUE(s)"` Mode perm.AccessMode }
Access represents the highest access level of a user to the repository. The only access type that is not in this table is the real owner of a repository. In case of an organization repository, the members of the owners team are in this table.
type Permission ¶
type Permission struct { AccessMode perm_model.AccessMode //Units []*repo_model.RepoUnit UnitsMode map[unit.Type]perm_model.AccessMode }
Permission contains all the permissions related variables to a repository for a user
func (*Permission) CanAccess ¶
func (p *Permission) CanAccess(mode perm_model.AccessMode, unitType unit.Type) bool
CanAccess returns true if user has mode access to the unit of the repository
func (*Permission) CanAccessAny ¶
func (p *Permission) CanAccessAny(mode perm_model.AccessMode, unitTypes ...unit.Type) bool
CanAccessAny returns true if user has mode access to any of the units of the repository
func (*Permission) CanRead ¶
func (p *Permission) CanRead(unitType unit.Type) bool
CanRead returns true if user could read to this unit
func (*Permission) CanReadAny ¶
func (p *Permission) CanReadAny(unitTypes ...unit.Type) bool
CanReadAny returns true if user has read access to any of the units of the repository
func (*Permission) CanReadIssuesOrPulls ¶
func (p *Permission) CanReadIssuesOrPulls(isPull bool) bool
CanReadIssuesOrPulls returns true if isPull is true and user could read pull requests and returns true if isPull is false and user could read to issues
func (*Permission) CanWrite ¶
func (p *Permission) CanWrite(unitType unit.Type) bool
CanWrite returns true if user could write to this unit
func (*Permission) CanWriteIssuesOrPulls ¶
func (p *Permission) CanWriteIssuesOrPulls(isPull bool) bool
CanWriteIssuesOrPulls returns true if isPull is true and user could write to pull requests and returns true if isPull is false and user could write to issues
func (*Permission) HasAccess ¶
func (p *Permission) HasAccess() bool
HasAccess returns true if the current user has at least read access to any unit of this repository
func (*Permission) IsAdmin ¶
func (p *Permission) IsAdmin() bool
IsAdmin returns true if current user has admin or higher access of repository.
func (*Permission) IsOwner ¶
func (p *Permission) IsOwner() bool
IsOwner returns true if current user is the owner of repository.
func (*Permission) UnitAccessMode ¶
func (p *Permission) UnitAccessMode(unitType unit.Type) perm_model.AccessMode
UnitAccessMode returns current user accessmode to the specify unit of the repository