Permission update
This commit is contained in:
parent
04fa8f53e1
commit
69e30bf10f
|
@ -10,6 +10,7 @@ import (
|
|||
type CS struct {
|
||||
Accounts struct {
|
||||
Gods []string
|
||||
Owners []string
|
||||
}
|
||||
Database struct {
|
||||
URI string
|
||||
|
@ -62,6 +63,7 @@ func LoadConfig(file []byte) {
|
|||
}
|
||||
|
||||
Config.Accounts.Gods = cfg.Section("accounts").Key("gods").Strings(",")
|
||||
Config.Accounts.Owners = cfg.Section("accounts").Key("owners").Strings(",")
|
||||
Config.Database.DropAllTables = cfg.Section("database").Key("drop").MustBool(false)
|
||||
Config.Database.URI = cfg.Section("database").Key("uri").String()
|
||||
if Config.Database.URI == "" {
|
||||
|
@ -166,6 +168,6 @@ func LoadConfig(file []byte) {
|
|||
|
||||
Config.Fortnite.Season = parsedSeason
|
||||
Config.Fortnite.Everything = cfg.Section("fortnite").Key("everything").MustBool(false)
|
||||
Config.Fortnite.Password = cfg.Section("fortnite").Key("password").MustBool(false)
|
||||
Config.Fortnite.Password = cfg.Section("fortnite").Key("disable_password").MustBool(false)
|
||||
Config.Fortnite.DisableClientCredentials = cfg.Section("fortnite").Key("disable_client_credentials").MustBool(false)
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
package person
|
||||
|
||||
import "github.com/ectrc/snow/aid"
|
||||
|
||||
type Permission int64
|
||||
|
||||
// DO NOT MOVE THE ORDER OF THESE PERMISSIONS AS THEY ARE USED IN THE DATABASE
|
||||
|
@ -16,33 +14,59 @@ const (
|
|||
PermissionOwner
|
||||
PermissionDonator
|
||||
|
||||
permissionRealAll = 1<<iota - 1
|
||||
// every permission except owner
|
||||
PermissionAll Permission = permissionRealAll ^ PermissionOwner
|
||||
// special permissions
|
||||
PermissionAll = PermissionLookup | PermissionBan | PermissionInformation | PermissionItemControl | PermissionLockerControl | PermissionPermissionControl
|
||||
PermissionAllWithRoles = PermissionAll | PermissionOwner | PermissionDonator
|
||||
)
|
||||
|
||||
func (p Permission) StringifyMe() string {
|
||||
aid.Print(p)
|
||||
switch p {
|
||||
case PermissionLookup:
|
||||
return "Lookup"
|
||||
case PermissionBan:
|
||||
return "Ban"
|
||||
case PermissionInformation:
|
||||
return "Information"
|
||||
case PermissionItemControl:
|
||||
return "ItemControl"
|
||||
case PermissionLockerControl:
|
||||
return "LockerControl"
|
||||
case PermissionPermissionControl:
|
||||
return "PermissionControl"
|
||||
case PermissionOwner:
|
||||
return "Owner"
|
||||
case PermissionDonator:
|
||||
return "Donator"
|
||||
case PermissionAll:
|
||||
return "All"
|
||||
default:
|
||||
return "Unknown"
|
||||
func (p Permission) GetName() string {
|
||||
if p == 0 {
|
||||
return "None"
|
||||
}
|
||||
|
||||
if p == PermissionAll {
|
||||
return "All"
|
||||
}
|
||||
|
||||
if p == PermissionAllWithRoles {
|
||||
return "AllWithRoles"
|
||||
}
|
||||
|
||||
if p&PermissionLookup != 0 {
|
||||
return "Lookup"
|
||||
}
|
||||
|
||||
if p&PermissionBan != 0 {
|
||||
return "Ban"
|
||||
}
|
||||
|
||||
if p&PermissionInformation != 0 {
|
||||
return "Information"
|
||||
}
|
||||
|
||||
if p&PermissionItemControl != 0 {
|
||||
return "ItemControl"
|
||||
}
|
||||
|
||||
if p&PermissionLockerControl != 0 {
|
||||
return "LockerControl"
|
||||
}
|
||||
|
||||
if p&PermissionPermissionControl != 0 {
|
||||
return "PermissionControl"
|
||||
}
|
||||
|
||||
if p&PermissionOwner != 0 {
|
||||
return "Owner"
|
||||
}
|
||||
|
||||
if p&PermissionDonator != 0 {
|
||||
return "Donator"
|
||||
}
|
||||
|
||||
return "Unknown"
|
||||
}
|
||||
|
||||
func IntToPermission(i int64) Permission {
|
||||
return Permission(i)
|
||||
}
|
|
@ -293,9 +293,9 @@ func (p *Person) RemovePermission(permission Permission) {
|
|||
}
|
||||
|
||||
func (p *Person) HasPermission(permission Permission) bool {
|
||||
if permission == PermissionAll {
|
||||
return p.Permissions == PermissionAll
|
||||
}
|
||||
// if permission == PermissionAll && permission != PermissionOwner {
|
||||
// return p.Permissions == PermissionAll
|
||||
// }
|
||||
|
||||
return p.Permissions & permission != 0
|
||||
}
|
||||
|
@ -406,6 +406,7 @@ func (p *Person) Snapshot() *PersonSnapshot {
|
|||
|
||||
func (p *Person) Delete() {
|
||||
storage.Repo.DeletePerson(p.ID)
|
||||
cache.DeletePerson(p.ID)
|
||||
}
|
||||
|
||||
func (p *Person) SetPurchaseHistoryAttribute() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user