internal/policy/snippets.go

c6c5cb340929ee44650344d2fe40f5badb7bd65a
gitbay/internal/policy/snippets.go

17 lines · 531 bytes

 1package policy
 2
 3import "gitbay.org/gitbay/internal/store"
 4
 5// CanReadSnippet: anyone for public and unlisted, the owner and admins
 6// for private. Anonymous readers have user.ID 0.
 7func CanReadSnippet(user store.User, sn store.Snippet) bool {
 8	if sn.Visibility != "private" {
 9		return true
10	}
11	return user.ID != 0 && (user.ID == sn.OwnerID || user.IsAdmin)
12}
13
14// CanWriteSnippet: the owner and admins.
15func CanWriteSnippet(user store.User, sn store.Snippet) bool {
16	return user.ID != 0 && (user.ID == sn.OwnerID || user.IsAdmin)
17}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form