2023-12-14 19:47:54 +00:00
|
|
|
package person
|
|
|
|
|
2024-02-09 23:56:06 +00:00
|
|
|
import "github.com/ectrc/snow/aid"
|
|
|
|
|
2024-02-09 21:51:26 +00:00
|
|
|
type Permission int64
|
2023-12-14 19:47:54 +00:00
|
|
|
|
2024-02-09 21:51:26 +00:00
|
|
|
// DO NOT MOVE THE ORDER OF THESE PERMISSIONS AS THEY ARE USED IN THE DATABASE
|
2023-12-14 19:47:54 +00:00
|
|
|
const (
|
2024-02-09 21:51:26 +00:00
|
|
|
PermissionLookup Permission = 1 << iota
|
|
|
|
PermissionBan
|
|
|
|
PermissionInformation
|
|
|
|
PermissionItemControl
|
|
|
|
PermissionLockerControl
|
|
|
|
PermissionPermissionControl
|
|
|
|
// user roles, not really permissions but implemented as such
|
|
|
|
PermissionOwner
|
|
|
|
PermissionDonator
|
2023-12-14 19:47:54 +00:00
|
|
|
|
2024-02-09 23:56:06 +00:00
|
|
|
permissionRealAll = 1<<iota - 1
|
|
|
|
// every permission except owner
|
|
|
|
PermissionAll Permission = permissionRealAll ^ PermissionOwner
|
|
|
|
)
|
|
|
|
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
}
|