work in progress

This commit is contained in:
ston1th 2018-09-04 23:15:47 +02:00
commit 07ff5ccffb
23 changed files with 228 additions and 240 deletions

47
pkg/core/permission.go Normal file
View file

@ -0,0 +1,47 @@
package core
type Permission int
const (
Invalid Permission = iota
Public
Internal
Private
)
func ParsePerm(p int) Permission {
switch p {
case 1:
return Public
case 2:
return Internal
case 3:
return Private
}
return Invalid
}
func ReadPerm(username string, p *Page) bool {
switch p.Perm {
case Public:
return true
case Internal:
return username != ""
case Private:
return username == p.Owner
}
return false
}
func WritePerm(username string, p *Page) bool {
switch p.Perm {
case Public, Internal:
if p.Owner == "" {
return username != ""
}
return username == p.Owner
case Private:
return username == p.Owner
}
return false
}