mirror of
https://github.com/documize/community.git
synced 2025-07-23 07:09:43 +02:00
parent
7fc74be7cd
commit
0e6f2f1f5e
2 changed files with 27 additions and 5 deletions
|
@ -147,6 +147,26 @@ func CanUploadDocument(ctx domain.RequestContext, s store.Store, spaceID string)
|
|||
return false
|
||||
}
|
||||
|
||||
// CanManageSpace returns if the user has permission to manage the given space.
|
||||
func CanManageSpace(ctx domain.RequestContext, s store.Store, spaceID string) bool {
|
||||
roles, err := s.Permission.GetUserSpacePermissions(ctx, spaceID)
|
||||
if err == sql.ErrNoRows {
|
||||
err = nil
|
||||
}
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
for _, role := range roles {
|
||||
if role.RefID == spaceID && role.Location == pm.LocationSpace && role.Scope == pm.ScopeRow &&
|
||||
pm.ContainsPermission(role.Action, pm.SpaceManage, pm.SpaceOwner) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
// CanViewSpace returns if the user has permission to view the given spaceID.
|
||||
func CanViewSpace(ctx domain.RequestContext, s store.Store, spaceID string) bool {
|
||||
roles, err := s.Permission.GetUserSpacePermissions(ctx, spaceID)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue