ripple-api/common/user_privileges.go

68 lines
1.4 KiB
Go
Raw Normal View History

package common
import "strings"
// user/admin privileges
const (
UserPrivilegePublic UserPrivileges = 1 << iota
UserPrivilegeNormal
UserPrivilegeDonor
AdminPrivilegeAccessRAP
AdminPrivilegeManageUsers
AdminPrivilegeBanUsers
AdminPrivilegeSilenceUsers
AdminPrivilegeWipeUsers
AdminPrivilegeManageBeatmap
AdminPrivilegeManageServer
AdminPrivilegeManageSetting
AdminPrivilegeManageBetaKey
AdminPrivilegeManageReport
AdminPrivilegeManageDocs
AdminPrivilegeManageBadges
AdminPrivilegeViewRAPLogs
AdminPrivilegeManagePrivilege
AdminPrivilegeSendAlerts
AdminPrivilegeChatMod
AdminPrivilegeKickUsers
UserPrivilegePendingVerification
2016-10-06 14:57:01 +00:00
UserPrivilegeTournamentStaff
)
// UserPrivileges represents a bitwise enum of the privileges of an user.
type UserPrivileges uint64
var userPrivilegeString = [...]string{
"UserPublic",
"UserNormal",
"UserDonor",
"AdminAccessRAP",
"AdminManageUsers",
"AdminBanUsers",
"AdminSilenceUsers",
"AdminWipeUsers",
"AdminManageBeatmap",
"AdminManageServer",
"AdminManageSetting",
"AdminManageBetaKey",
"AdminManageReport",
"AdminManageDocs",
"AdminManageBadges",
"AdminViewRAPLogs",
"AdminManagePrivilege",
"AdminSendAlerts",
"AdminChatMod",
"AdminKickUsers",
"UserPendingVerification",
2016-10-06 14:57:01 +00:00
"UserTournamentStaff",
}
func (p UserPrivileges) String() string {
var pvs []string
for i, v := range userPrivilegeString {
if uint64(p)&uint64(1<<uint(i)) != 0 {
pvs = append(pvs, v)
}
}
return strings.Join(pvs, ", ")
}