added user independent sections and started db migration work
This commit is contained in:
parent
6a2dc8146c
commit
16ea95bf09
24 changed files with 622 additions and 122 deletions
|
|
@ -7,7 +7,6 @@ type Permission int
|
|||
const (
|
||||
Invalid Permission = iota
|
||||
Public
|
||||
Internal
|
||||
Private
|
||||
)
|
||||
|
||||
|
|
@ -16,37 +15,27 @@ func ParsePermString(p string) Permission {
|
|||
case "1":
|
||||
return Public
|
||||
case "2":
|
||||
return Internal
|
||||
case "3":
|
||||
return Private
|
||||
}
|
||||
return Invalid
|
||||
}
|
||||
|
||||
func ReadPerm(username string, p *Page) bool {
|
||||
switch p.Perm {
|
||||
func ReadPerm(username string, p Permission, s Section) bool {
|
||||
switch p {
|
||||
case Public:
|
||||
return true
|
||||
case Internal:
|
||||
return username != ""
|
||||
case Private:
|
||||
return username == p.Owner
|
||||
_, c := Contains(username, s.Members)
|
||||
return c
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func WritePerm(username, section string, p *Page) bool {
|
||||
if section != WikiSection && section != username {
|
||||
return false
|
||||
}
|
||||
switch p.Perm {
|
||||
case Public, Internal:
|
||||
if p.Owner == WikiSection {
|
||||
return username != ""
|
||||
}
|
||||
return username == p.Owner
|
||||
case Private:
|
||||
return username == p.Owner
|
||||
func WritePerm(username string, p Permission, s Section) bool {
|
||||
switch p {
|
||||
case Public, Private:
|
||||
_, c := Contains(username, s.Members)
|
||||
return c
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue